Zelda Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2023-08-12 03:18:08
Exec Total Coverage
Lines: 8537 12240 69.7%
Functions: 325 397 81.9%
Branches: 6736 13792 48.8%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // guys.cc
6 //
7 // "Guys" code (and other related stuff) for zelda.cc
8 //
9 //--------------------------------------------------------
10
11 #include <string.h>
12 #include <stdio.h>
13 #include "base/zc_alleg.h"
14 #include "zc/guys.h"
15 #include "zc/replay.h"
16 #include "zc/zelda.h"
17 #include "base/zsys.h"
18 #include "base/msgstr.h"
19 #include "zc/maps.h"
20 #include "zc/hero.h"
21 #include "subscr.h"
22 #include "zc/ffscript.h"
23 #include "gamedata.h"
24 #include "defdata.h"
25 #include "zscriptversion.h"
26 #include "particles.h"
27 #include "base/zc_math.h"
28 #include "slopes.h"
29 #include "base/qrs.h"
30 #include "base/dmap.h"
31 #include "base/mapscr.h"
32 #include "base/misctypes.h"
33 extern particle_list particles;
34
35 extern FFScript FFCore;
36 extern ZModule zcm;
37 extern HeroClass Hero;
38 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
39 extern zinitdata zinit;
40
41 int32_t repaircharge=0;
42 bool adjustmagic=false;
43 bool learnslash=false;
44 int32_t wallm_load_clk=0;
45 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
46 int32_t vhead=0;
47 int32_t guycarryingitem=0;
48
49 char *guy_string[eMAXGUYS];
50
51 void never_return(int32_t index);
52 void playLevelMusic();
53
54 // If an enemy is this far out of the playing field, just remove it.
55 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
56 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
57 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
58 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
59
60 648889 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
61 {
62 648889 int32_t c = coord.getInt();
63
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 648622 times.
648889 if(nearest_half)
64 {
65
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648622 times.
648622 if (c < 0)
66 c -= val / 2;
67 648622 else c += (val/2);
68 648622 }
69 648889 c -= c % val;
70 648889 coord = c;
71 648889 }
72
73 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
74 {
75 return
76 (
77 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
78 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
79 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
80 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
81 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
82 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
83 );
84 }
85
86 namespace
87 {
88 int32_t trapConstantHorizontalID;
89 int32_t trapConstantVerticalID;
90 int32_t trapLOSHorizontalID;
91 int32_t trapLOSVerticalID;
92 int32_t trapLOS4WayID;
93
94 int32_t cornerTrapID;
95 int32_t centerTrapID;
96
97 int32_t rockID;
98 int32_t zoraID;
99 int32_t statueID;
100 }
101
102 121 void identifyCFEnemies()
103 {
104 121 trapConstantHorizontalID=-1;
105 121 trapConstantVerticalID=-1;
106 121 trapLOSHorizontalID=-1;
107 121 trapLOSVerticalID=-1;
108 121 trapLOS4WayID=-1;
109 121 cornerTrapID=-1;
110 121 centerTrapID=-1;
111 121 rockID=-1;
112 121 zoraID=-1;
113 121 statueID=-1;
114
115
2/2
✓ Branch 0 taken 61952 times.
✓ Branch 1 taken 121 times.
62073 for(int32_t i=0; i<eMAXGUYS; i++)
116 {
117
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61952 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
118 120 trapLOSHorizontalID=i;
119
4/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 61828 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
120 121 trapLOSVerticalID=i;
121
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
122 121 trapLOS4WayID=i;
123
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
124 121 trapConstantHorizontalID=i;
125
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
126 121 trapConstantVerticalID=i;
127
128
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
129 121 cornerTrapID=i;
130
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
131 121 centerTrapID=i;
132
133
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
134 121 rockID=i;
135
4/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 61826 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
136 121 zoraID=i;
137
138
4/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 61825 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
139 121 statueID=i;
140 61952 }
141 121 }
142
143 25 int32_t random_layer_enemy()
144 {
145 25 int32_t cnt=count_layer_enemies();
146
147
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
148 {
149 return eNONE;
150 }
151
152 25 int32_t ret=zc_oldrand()%cnt;
153 25 cnt=0;
154
155
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
156 {
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
158 {
159 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
160
161
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
162 {
163
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
164 {
165
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
166 {
167 25 return layerscreen->enemy[j];
168 }
169
170 102 ++cnt;
171 102 }
172 102 }
173 }
174 }
175
176 return eNONE;
177 25 }
178
179 39 int32_t count_layer_enemies()
180 {
181 39 int32_t cnt=0;
182
183
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
184 {
185
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
186 {
187 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
188
189
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
190 {
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
192 {
193 390 ++cnt;
194 390 }
195 390 }
196 39 }
197 234 }
198
199 39 return cnt;
200 }
201
202 145542 int32_t hero_on_wall()
203 {
204 145542 zfix lx = Hero.getX();
205 145542 zfix ly = Hero.getY();
206
207
208 //zprint2("hero_on_wall x is: %d\n", lx);
209 //zprint2("hero_on_wall y is: %d\n", ly);
210
211
4/4
✓ Branch 0 taken 135889 times.
✓ Branch 1 taken 9653 times.
✓ Branch 2 taken 4526 times.
✓ Branch 3 taken 131363 times.
145542 if(lx>=48 && lx<=192)
212 {
213
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 131211 times.
131363 if(ly==32) return up+1;
214
215
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 131051 times.
131211 if(ly==128) return down+1;
216 131051 }
217
218
4/4
✓ Branch 0 taken 134471 times.
✓ Branch 1 taken 10759 times.
✓ Branch 2 taken 11441 times.
✓ Branch 3 taken 123030 times.
145230 if(ly>=48 && ly<=112)
219 {
220
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 122898 times.
123030 if(lx==32) return left+1;
221
222
2/2
✓ Branch 0 taken 122829 times.
✓ Branch 1 taken 69 times.
122898 if(lx==208) return right+1;
223 122829 }
224
225 145029 return 0;
226 145542 }
227
228 690682 bool tooclose(int32_t x,int32_t y,int32_t d)
229 {
230
2/2
✓ Branch 0 taken 511178 times.
✓ Branch 1 taken 179504 times.
690682 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
231 }
232
233 2107695 bool enemy::overpit(enemy *e)
234 {
235 // This function (and shadow_overpit) has been broken since it was written, and only
236 // checked the same diagonal of the hitbox, over and over again. The bug is because both
237 // loops used the same variable name.
238 // Checking literally every pixel seems like overkill, so for now let's continue to
239 // do the single diagonal but just once. That's why the outer loop is commented out.
240
241 // for ( int32_t q = 0; q < hxsz; ++q )
242 {
243
2/2
✓ Branch 0 taken 19856068 times.
✓ Branch 1 taken 2104527 times.
21960595 for ( int32_t q = 0; q < hit_height; ++q )
244 {
245 //check every pixel of the hitbox
246
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 19852900 times.
19856068 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
247 {
248 //if the hitbox is over a pit, we can't land
249 3168 return true;
250 }
251 19852900 }
252 }
253 2104527 return false;
254 2107695 }
255
256 4517527 bool enemy::shadow_overpit(enemy *e)
257 {
258 // for ( int32_t q = 0; q < hxsz; ++q )
259 {
260
2/2
✓ Branch 0 taken 66511914 times.
✓ Branch 1 taken 4513675 times.
71025589 for ( int32_t q = 0; q < hit_height; ++q )
261 {
262 //check every pixel of the hitbox
263
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 66508062 times.
66511914 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
264 {
265 //if the hitbox is over a pit, we can't land
266 3852 return true;
267 }
268 66508062 }
269 }
270 4513675 return false;
271 4517527 }
272
273 // Returns true iff a combo type or flag precludes enemy movement.
274 3796948 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
275 {
276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3796948 times.
3796948 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
277 3796948 int32_t c = COMBOTYPE(dx,dy);
278
4/4
✓ Branch 0 taken 2492212 times.
✓ Branch 1 taken 1304736 times.
✓ Branch 2 taken 656349 times.
✓ Branch 3 taken 648387 times.
5101684 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
279
3/6
✓ Branch 0 taken 1290936 times.
✓ Branch 1 taken 2506012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1290936 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3796948 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN));
280
4/6
✓ Branch 0 taken 1326413 times.
✓ Branch 1 taken 2470535 times.
✓ Branch 2 taken 1326413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1326413 times.
✗ Branch 5 not taken.
7594499 return c==cPIT || c==cPITB || c==cPITC ||
281
4/6
✓ Branch 0 taken 1326413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1326413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1236918 times.
✓ Branch 5 taken 89495 times.
1326413 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
282 // Block enemies type and block enemies flags
283
2/2
✓ Branch 0 taken 1325064 times.
✓ Branch 1 taken 1235569 times.
89495 combo_class_buf[c].block_enemies&1 ||
284
3/4
✓ Branch 0 taken 1325061 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1325061 times.
✗ Branch 3 not taken.
1325064 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
285
4/4
✓ Branch 0 taken 1324737 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 1324724 times.
✓ Branch 3 taken 13 times.
1325061 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
286 // Check for ladder-only combos which aren't dried water
287
4/4
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 1324130 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 5 times.
2649443 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
288 // Check for drownable water
289
4/4
✓ Branch 0 taken 102957 times.
✓ Branch 1 taken 1221762 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 101057 times.
1324719 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
290 1327016 }
291
292 // Returns true iff enemy is floating and blocked by a combo type or flag.
293 4618306 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
294 {
295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4618306 times.
4618306 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
296
4/4
✓ Branch 0 taken 2869530 times.
✓ Branch 1 taken 1748776 times.
✓ Branch 2 taken 1521446 times.
✓ Branch 3 taken 227330 times.
6367082 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
297
3/4
✓ Branch 0 taken 2879534 times.
✓ Branch 1 taken 1738772 times.
✓ Branch 2 taken 1738772 times.
✗ Branch 3 not taken.
6357078 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
298
2/2
✓ Branch 0 taken 557235 times.
✓ Branch 1 taken 4061071 times.
8679377 return ((special==spw_floater)&&
299
2/2
✓ Branch 0 taken 4054933 times.
✓ Branch 1 taken 6138 times.
4061071 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
300
1/2
✓ Branch 0 taken 4054933 times.
✗ Branch 1 not taken.
4054933 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
301
2/2
✓ Branch 0 taken 4054796 times.
✓ Branch 1 taken 137 times.
4054933 (MAPFLAG(dx,dy)==mfNOENEMY)||
302
1/2
✓ Branch 0 taken 4054796 times.
✗ Branch 1 not taken.
4054796 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
303
4/4
✓ Branch 0 taken 1240951 times.
✓ Branch 1 taken 2813845 times.
✓ Branch 2 taken 3939 times.
✓ Branch 3 taken 1237012 times.
8105653 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
304
2/2
✓ Branch 0 taken 2807382 times.
✓ Branch 1 taken 1243475 times.
4050857 (pit_blocks && ispitfall(dx,dy))));
305 4618306 }
306 // Returns true iff a combo type or flag precludes enemy movement.
307 242813 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
308 {
309 242813 int32_t c = COMBOTYPE(dx,dy);
310 242813 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
311
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 215488 times.
242813 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN);
312
4/6
✓ Branch 0 taken 242812 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 242812 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242812 times.
✗ Branch 5 not taken.
922959 return c==cPIT || c==cPITB || c==cPITC ||
313
4/6
✓ Branch 0 taken 242812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242812 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 218777 times.
✓ Branch 5 taken 24035 times.
242812 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
314 // Block enemies type and block enemies flags
315
2/2
✓ Branch 0 taken 242702 times.
✓ Branch 1 taken 218667 times.
24035 combo_class_buf[c].block_enemies&1 ||
316
3/4
✓ Branch 0 taken 242554 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 242554 times.
✗ Branch 3 not taken.
242702 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
317
4/4
✓ Branch 0 taken 239058 times.
✓ Branch 1 taken 3496 times.
✓ Branch 2 taken 238786 times.
✓ Branch 3 taken 272 times.
242554 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
318 // Check for ladder-only combos which aren't dried water
319
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 238755 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
477572 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
320 // Check for drownable water
321
4/4
✓ Branch 0 taken 32350 times.
✓ Branch 1 taken 206436 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 8346 times.
238786 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
322 }
323
324 // Returns true iff enemy is floating and blocked by a combo type or flag.
325 115623 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
326 {
327
2/2
✓ Branch 0 taken 113300 times.
✓ Branch 1 taken 2323 times.
115623 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
328 115623 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115623 times.
231246 return ((special==spw_floater)&&
330
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 2 times.
115623 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
331
1/2
✓ Branch 0 taken 115621 times.
✗ Branch 1 not taken.
115621 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
332
2/2
✓ Branch 0 taken 115617 times.
✓ Branch 1 taken 4 times.
115621 (MAPFLAG(dx,dy)==mfNOENEMY)||
333
1/2
✓ Branch 0 taken 115617 times.
✗ Branch 1 not taken.
115617 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
334
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 113296 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
230984 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
335
2/2
✓ Branch 0 taken 113296 times.
✓ Branch 1 taken 2071 times.
115367 (pit_blocks && ispitfall(dx,dy))));
336 }
337
338 /**********************************/
339 /******* Enemy Base Class *******/
340 /**********************************/
341
342
5/10
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58114 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58114 times.
✗ Branch 9 not taken.
174342 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 116228 {
344
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 x=X;
345
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 y=Y;
346 58114 id=Id;
347 58114 clk=Clk;
348
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 floor_y=y;
349 58114 ceiling=false;
350 58114 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
351 58114 grumble = movestatus = posframe = timer = ox = oy = 0;
352
4/8
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58114 times.
✓ Branch 4 taken 58114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58114 times.
✗ Branch 7 not taken.
58114 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
353 58114 did_armos=true;
354 58114 script_spawned=false;
355
356 58114 d = guysbuf + (id & 0xFFF);
357 58114 hp = d->hp;
358 58114 starting_hp = hp;
359 // cs = d->cset;
360 //d variables
361
362 58114 flags=d->flags;
363 58114 flags2=d->flags2;
364 58114 s_tile=d->s_tile; //secondary (additional) tile(s)
365 58114 family=d->family;
366 58114 dcset=d->cset;
367 58114 cs=dcset;
368
3/4
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38814 times.
✓ Branch 3 taken 19300 times.
58114 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
369 58114 dp=d->dp;
370 58114 wdp=d->wdp;
371 58114 wpn=d->weapon;
372 58114 wpnsprite = d-> wpnsprite; //2.6 -Z
373 58114 rate=d->rate;
374 58114 hrate=d->hrate;
375
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 dstep=d->step;
376 58114 homing=d->homing;
377 58114 dmisc1=d->misc1;
378 58114 dmisc2=d->misc2;
379 58114 dmisc3=d->misc3;
380 58114 dmisc4=d->misc4;
381 58114 dmisc5=d->misc5;
382 58114 dmisc6=d->misc6;
383 58114 dmisc7=d->misc7;
384 58114 dmisc8=d->misc8;
385 58114 dmisc9=d->misc9;
386 58114 dmisc10=d->misc10;
387 58114 dmisc11=d->misc11;
388 58114 dmisc12=d->misc12;
389 58114 dmisc13=d->misc13;
390 58114 dmisc14=d->misc14;
391 58114 dmisc15=d->misc15;
392 58114 dmisc16=d->misc16;
393 58114 dmisc17=d->misc17;
394 58114 dmisc18=d->misc18;
395 58114 dmisc19=d->misc19;
396 58114 dmisc20=d->misc20;
397 58114 dmisc21=d->misc21;
398 58114 dmisc22=d->misc22;
399 58114 dmisc23=d->misc23;
400 58114 dmisc24=d->misc24;
401 58114 dmisc25=d->misc25;
402 58114 dmisc26=d->misc26;
403 58114 dmisc27=d->misc27;
404 58114 dmisc28=d->misc28;
405 58114 dmisc29=d->misc29;
406 58114 dmisc30=d->misc30;
407 58114 dmisc31=d->misc31;
408 58114 dmisc32=d->misc32;
409
3/4
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 435 times.
✓ Branch 3 taken 57679 times.
58114 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
410 {
411 57679 dmisc31 = dmisc32;
412 57679 dmisc32 = 0;
413 57679 }
414 58114 spr_shadow=d->spr_shadow;
415 58114 spr_death=d->spr_death;
416 58114 spr_spawn=d->spr_spawn;
417
418
2/2
✓ Branch 0 taken 2382674 times.
✓ Branch 1 taken 58114 times.
2440788 for(int32_t i=0; i<edefLAST255; i++)
419 2382674 defense[i]=d->defense[i];
420
421 58114 bgsfx=d->bgsfx;
422 58114 hitsfx=d->hitsfx;
423 58114 deadsfx=d->deadsfx;
424 58114 bosspal=d->bosspal;
425 58114 parent_script_UID = 0;
426
427 58114 frozentile = d->frozentile;
428
429 58114 frozencset = d->frozencset;
430 58114 frozenclock = 0;
431
2/2
✓ Branch 0 taken 581140 times.
✓ Branch 1 taken 58114 times.
639254 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 58114 times.
✓ Branch 1 taken 987938 times.
1046052 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 58114 isCore = true; //t.b.a
436 58114 parentCore = 0; //t.b.a
437
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
438
439 58114 firesfx = d->firesfx;
440
2/2
✓ Branch 0 taken 1859648 times.
✓ Branch 1 taken 58114 times.
1917762 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
441
2/2
✓ Branch 0 taken 1859648 times.
✓ Branch 1 taken 58114 times.
1917762 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
442
443
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
444 58114 waitdraw = 0;
445
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
446
447
2/2
✓ Branch 0 taken 464912 times.
✓ Branch 1 taken 58114 times.
523026 for ( int32_t q = 0; q < 8; q++ )
448 {
449 464912 initD[q] = d->initD[q];
450 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
451 464912 weap_initiald[q] = d->weap_initiald[q];
452 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
453 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
454 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
455 464912 }
456
2/2
✓ Branch 0 taken 116228 times.
✓ Branch 1 taken 58114 times.
174342 for ( int32_t q = 0; q < 2; q++ )
457 {
458 116228 initA[q] = d->initA[q];
459 116228 weap_initiala[q] = d->weap_initiala[q];
460 116228 }
461
462 58114 stickclk = 0;
463 58114 submerged = false;
464 58114 didScriptThisFrame = false;
465 58114 ffcactivated = 0;
466 58114 hitdir = -1;
467 58114 dialogue_str = 0; //set by spawn flags.
468 58114 editorflags = d->editorflags; //set by Enemy Editor
469 //Set the drawing flag for this sprite.
470
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
471
472
473
2/2
✓ Branch 0 taken 8231 times.
✓ Branch 1 taken 49883 times.
58114 if(bosspal>-1)
474 {
475
1/2
✓ Branch 0 taken 8231 times.
✗ Branch 1 not taken.
8231 loadpalset(csBOSS,pSprite(bosspal));
476 8231 }
477
478
2/2
✓ Branch 0 taken 26008 times.
✓ Branch 1 taken 32106 times.
58114 if(bgsfx>-1)
479 {
480
1/2
✓ Branch 0 taken 26008 times.
✗ Branch 1 not taken.
26008 cont_sfx(bgsfx);
481 26008 }
482
483
3/4
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38814 times.
✓ Branch 3 taken 19300 times.
58114 if(get_qr(qr_NEWENEMYTILES))
484 {
485 38814 o_tile=d->e_tile;
486 38814 frate = d->e_frate;
487 38814 }
488 else
489 {
490 19300 o_tile=d->tile;
491 19300 frate = d->frate;
492 }
493
494 58114 tile=0; //init to 0 here, but set it later.
495
496 58114 scripttile = -1;
497 58114 scriptflip = -1;
498 58114 do_animation = 1;
499 58114 immortal = false;
500 58114 noSlide = false;
501 58114 deathexstate = -1;
502
503 58114 hashero=false;
504
505 // If they forgot the invisibility flag, here's another failsafe:
506
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 55256 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2764 times.
58114 if(o_tile==0 && family!=eeSPINTILE)
507 2764 flags |= guy_invisible;
508
509 // step = d->step/100.0;
510 // To preserve the odd step values for Keese & Gleeok heads. -L
511
5/8
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6746 times.
✓ Branch 5 taken 51368 times.
✓ Branch 6 taken 6746 times.
✗ Branch 7 not taken.
58114 if(dstep==62.0) dstep+=0.5;
512
5/8
✓ Branch 0 taken 51368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 51008 times.
✓ Branch 6 taken 360 times.
✗ Branch 7 not taken.
51368 else if(dstep==89) dstep-=1/9;
513
514
5/10
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58114 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58114 times.
✗ Branch 9 not taken.
58114 step = zslongToFix(dstep*100);
515
516
517 58114 item_set = d->item_set;
518 58114 grumble = d->grumble;
519
520
2/2
✓ Branch 0 taken 45386 times.
✓ Branch 1 taken 12728 times.
58114 if(frate == 0)
521 12728 frate = 256;
522
523 58114 leader = itemguy = dying = scored = false;
524 58114 canfreeze = count_enemy = true;
525 58114 mainguy = !(flags & guy_doesntcount);
526
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 dir = zc_oldrand()&3;
527
528 //2.6 Enemy Editor Hit and TIle Sizes
529
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58114 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
530 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
531 // al_trace("Enemy txsz:%i\n", txsz);
532
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58114 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58114 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58114 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58114 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
536
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
537
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
538 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58114 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
58114 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
541 {
542 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
543 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
544 }
545
546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58114 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
547
548 58114 SIZEflags = d->SIZEflags;
549
550
8/10
✓ Branch 0 taken 58026 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 58026 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
58114 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
551 1 wpn = 0;
552
553 //tile should never be 0 after init --Z (failsafe)
554
4/6
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57108 times.
✓ Branch 5 taken 1006 times.
58114 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
555
556 //Moveflags; for gravity and pit interaction
557 58114 moveflags = d->moveflags;
558
3/4
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50646 times.
✓ Branch 3 taken 7468 times.
58114 if(!can_pitfall(false))
559 {
560 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
561 7468 moveflags &= ~FLAG_CAN_PITFALL;
562 7468 moveflags &= ~FLAG_CAN_WATERDROWN;
563 7468 }
564
565
1/2
✓ Branch 0 taken 58114 times.
✗ Branch 1 not taken.
58114 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
566 58114 }
567
568 598 int32_t enemy::getScriptUID() { return script_UID; }
569 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
570 58086 enemy::~enemy()
571 58086 {
572
2/4
✓ Branch 0 taken 58086 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58086 times.
✗ Branch 3 not taken.
58086 FFCore.deallocateAllArrays(ScriptType::NPC, getUID());
573
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 58082 times.
58086 if(hashero)
574 {
575
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Hero.setEaten(0);
576 4 hashero=false;
577 4 }
578 58086 }
579
580
581 bool enemy::is_move_paused()
582 {
583 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
584 }
585
586 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
587 {
588 int32_t yg = (special==spw_floater)?8:0;
589 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
590 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
591 if(input_x == -1000)
592 input_x = dx;
593 if(input_y == -1000)
594 input_y = dy;
595
596 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
597 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
598 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
599 return true;
600
601 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
602 {
603 if(ispitfall(dx,dy))
604 return true;
605 }
606
607 bool flying = false;
608 bool cansolid = false;
609 if(moveflags & FLAG_IGNORE_SOLIDITY)
610 cansolid = true;
611 switch(special)
612 {
613 case spw_clipbottomright:
614 if(dy>=128 || dx>=208) return true;
615 break;
616 case spw_clipright:
617 break; //if(input_x>=208) return true; break;
618
619 case spw_wizzrobe: // fall through
620 case spw_floater: // Special case for fliers and wizzrobes - hack!
621 {
622 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
623 {
624 if(dy < 32-yg || dy >= 144) return true;
625 if(dx < 32 || dx >= 224) return true;
626 }
627 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
628 return true;
629 cansolid = true;
630 flying = true;
631 }
632 }
633
634 dx &= ~7;
635 dy &= ~7;
636
637 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
638
639 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
640 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
641 //_walkflag code
642 mapscr *s1, *s2;
643 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
644 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
645
646 int32_t cpos=(dx>>4)+(dy&0xF0);
647 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
648 newcombo const& c = combobuf[ci];
649 newcombo const& c1 = combobuf[ci1];
650 newcombo const& c2 = combobuf[ci2];
651
652 int32_t b=1;
653 if(dx&8) b<<=2;
654 if(dy&8) b<<=1;
655
656 #define iwtr(cmb, x, y, shallow) \
657 (shallow \
658 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
659 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
660 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
661 bool wtr = iwtr(ci, dx, dy, false);
662 bool shwtr = iwtr(ci, dx, dy, true);
663 bool pit = ispitfall(dx,dy);
664
665 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
666 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
667 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
668 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
669 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
670
671 if(!cansolid)
672 {
673 int32_t cwalkflag = c.walk & 0xF;
674 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
675 if (s1)
676 {
677 if (c1.type == cBRIDGE)
678 {
679 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
680 {
681 int efflag = (c1.walk & 0xF0)>>4;
682 int newsolid = (c1.walk & 0xF);
683 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
684 }
685 else cwalkflag &= c1.walk;
686 }
687 else cwalkflag |= c1.walk & 0xF;
688 }
689 if (s2)
690 {
691 if (c2.type == cBRIDGE)
692 {
693 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
694 {
695 int efflag = (c2.walk & 0xF0)>>4;
696 int newsolid = (c2.walk & 0xF);
697 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
698 }
699 else cwalkflag &= c2.walk;
700 }
701 else cwalkflag |= c2.walk & 0xF;
702 }
703 if(cwalkflag & b)
704 return true;
705 }
706 if(needwtr || needshwtr || needpit)
707 {
708 bool ret = true;
709 if (needwtr && wtr) ret = false;
710 else if (needshwtr && shwtr) ret = false;
711 else if (needpit && pit) ret = false;
712 return ret;
713 }
714 else if(wtr && !canwtr)
715 return true;
716 else if(pit && !canpit)
717 return true;
718
719 return false;
720 }
721
722 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
723 {
724 if(!(dx || dy)) return true;
725 zfix bx = x+hxofs, by = y+hyofs; //left/top
726 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
727 if(!ign_sv && dy < 0) //check gravity
728 {
729 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
730 return false;
731 }
732
733 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
734
735 if(dx && !dy)
736 {
737 if(dx < 0)
738 {
739 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
740 int mx = (bx+dx).getFloor();
741 for(zfix ty = 0; by+ty < ry; ty += 8)
742 {
743 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
744 return false;
745 }
746 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
747 return false;
748 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
749 return false;
750 }
751 else
752 {
753 int mx = (rx+dx).getCeil();
754 int lx = mx-hit_width+1;
755 for(zfix ty = 0; by+ty < ry; ty += 8)
756 {
757 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
758 return false;
759 }
760 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
761 return false;
762 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
763 return false;
764 }
765 }
766 else if(dy && !dx)
767 {
768 if(dy < 0)
769 {
770 special = (special==spw_clipbottomright)?spw_none:special;
771 int my = (by+dy).getFloor();
772 for(zfix tx = 0; bx+tx < rx; tx += 8)
773 {
774 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
775 return false;
776 }
777 if(scr_walkflag(rx, my, special, up, bx, my, kb))
778 return false;
779 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
780 return false;
781 }
782 else
783 {
784 int my = (ry+dy).getCeil();
785 int ly = my-hit_height+1;
786 for(zfix tx = 0; bx+tx < rx; tx += 8)
787 {
788 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
789 return false;
790 }
791 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
792 return false;
793 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
794 return false;
795 }
796 }
797 else //! Untested, and currently unused.
798 {
799 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
800 }
801 return true;
802 }
803
804 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
805 {
806 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
807 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
808
809 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
810
811 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
812 return false;
813 for(zfix ty = 0; by+ty < ry; ty += 8)
814 {
815 for(zfix tx = 0; bx+tx < rx; tx += 8)
816 {
817 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
818 return false;
819 }
820 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
821 return false;
822 }
823 for(zfix tx = 0; bx+tx < rx; tx += 8)
824 {
825 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
826 return false;
827 }
828 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
829 return false;
830 return true;
831 }
832
833 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
834 {
835 auto oxsz = hit_width, oysz = hit_height;
836 if(nwid > -1) hit_width = nwid;
837 if(nhei > -1) hit_height = nhei;
838 bool ret = scr_canplace(dx,dy,special,kb);
839 hit_width = oxsz; hit_height = oysz;
840 return ret;
841 }
842
843 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
844 {
845 bool ret = true;
846 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
847 dy = 0;
848 const int scl = 2;
849 while(abs(dx) > scl || abs(dy) > scl)
850 {
851 if(abs(dx) > abs(dy))
852 {
853 int32_t tdx = dx.sign() * scl;
854 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
855 dx -= tdx;
856 else
857 {
858 if(earlyret) return false;
859 dx = tdx;
860 ret = false;
861 }
862 }
863 else
864 {
865 int32_t tdy = dy.sign() * scl;
866 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
867 dy -= tdy;
868 else
869 {
870 if(earlyret) return false;
871 dy = tdy;
872 ret = false;
873 }
874 }
875 }
876
877 if(dx)
878 {
879 if(scr_canmove(dx, 0, special, kb, ign_sv))
880 x += dx;
881 else
882 {
883 if(earlyret) return false;
884 ret = false;
885 int xsign = dx.sign();
886 while(scr_canmove(xsign, 0, special, kb, ign_sv))
887 {
888 x += xsign;
889 dx -= xsign;
890 }
891 if(dx)
892 {
893 dx.doDecBound(0,-9999, 0,9999);
894 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
895 if(scr_canmove(val, 0, special, kb, ign_sv))
896 {
897 retval = val;
898 return BSEARCH_CONTINUE_AWAY0;
899 }
900 else return BSEARCH_CONTINUE_TOWARD0;
901 });
902 x += dx;
903 }
904 }
905 }
906 if(dy)
907 {
908 if(scr_canmove(0, dy, special, kb, ign_sv))
909 y += dy;
910 else
911 {
912 if(earlyret) return false;
913 ret = false;
914 int ysign = dy.sign();
915 while(scr_canmove(0, ysign, special, kb, ign_sv))
916 {
917 y += ysign;
918 dy -= ysign;
919 }
920 if(dy)
921 {
922 dy.doDecBound(0,-9999, 0,9999);
923 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
924 if(scr_canmove(0, val, special, kb, ign_sv))
925 {
926 retval = val;
927 return BSEARCH_CONTINUE_AWAY0;
928 }
929 else return BSEARCH_CONTINUE_TOWARD0;
930 });
931 y += dy;
932 }
933 }
934 }
935 return ret;
936 }
937
938 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
939 {
940 static const zfix diagrate = zslongToFix(7071);
941 switch(NORMAL_DIR(dir))
942 {
943 case up:
944 return movexy(0, -px, special, kb, false, earlyret);
945 case down:
946 return movexy(0, px, special, kb, false, earlyret);
947 case left:
948 return movexy(-px, 0, special, kb, false, earlyret);
949 case right:
950 return movexy(px, 0, special, kb, false, earlyret);
951 case r_up:
952 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
953 case r_down:
954 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
955 case l_up:
956 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
957 case l_down:
958 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
959 }
960 return false;
961 }
962
963 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
964 {
965 double v = degrees.getFloat() * PI / 180.0;
966 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
967 return movexy(dx, dy, special, kb, false, earlyret);
968 }
969
970 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
971 {
972 zfix tx = x, ty = y;
973 bool ret = movexy(dx, dy, special, kb, false, true);
974 x = tx;
975 y = ty;
976 return ret;
977 }
978 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
979 {
980 zfix tx = x, ty = y;
981 bool ret = moveDir(dir, px, special, kb, true);
982 x = tx;
983 y = ty;
984 return ret;
985 }
986 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
987 {
988 zfix tx = x, ty = y;
989 bool ret = moveAtAngle(degrees, px, special, kb, true);
990 x = tx;
991 y = ty;
992 return ret;
993 }
994
995 // Handle pitfalls
996 21147479 bool enemy::do_falling(int32_t index)
997 {
998
2/2
✓ Branch 0 taken 21147337 times.
✓ Branch 1 taken 142 times.
21147479 if(fallclk > 0)
999 {
1000
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
1001
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
1002 {
1003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
1004 ++fallclk; //force another frame of falling.... forever.
1005
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
1006 {
1007
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
1008 never_return(index);
1009
1010
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
1011 kill_em_all();
1012
1013 //leave_item(); //Don't drop items in pits!
1014 2 stop_bgsfx(index);
1015 2 return true;
1016 }
1017 else
1018 {
1019 2 try_death(true); //Force death
1020 2 ++fallclk; //force another frame of falling
1021 }
1022 2 }
1023
1024 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1025 140 cs = spr.csets & 0xF;
1026
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
1027
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
1028 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1029
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
1030 140 }
1031 21147477 return false;
1032 21147479 }
1033
1034 // Handle drowning in water
1035 21147337 bool enemy::do_drowning(int32_t index)
1036 {
1037
1/2
✓ Branch 0 taken 21147337 times.
✗ Branch 1 not taken.
21147337 if(drownclk > 0)
1038 {
1039 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1040 //!TODO: Drown SFX
1041 if(!--drownclk)
1042 {
1043 if(immortal) //Keep alive forever
1044 ++drownclk; //force another frame of falling.... forever.
1045 else if(dying) //Give 1 frame for script revival
1046 {
1047 if(flags&guy_neverret)
1048 never_return(index);
1049
1050 if(leader)
1051 kill_em_all();
1052
1053 //leave_item(); //Don't drop items in pits!
1054 stop_bgsfx(index);
1055 return true;
1056 }
1057 else
1058 {
1059 try_death(true); //Force death
1060 ++drownclk; //force another frame of falling
1061 }
1062 }
1063
1064 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1065 {
1066 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1067 cs = spr.csets & 0xF;
1068 int32_t fr = spr.frames ? spr.frames : 1;
1069 int32_t spd = spr.speed ? spr.speed : 1;
1070 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1071 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1072 }
1073 else
1074 {
1075 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1076 cs = spr.csets & 0xF;
1077 int32_t fr = spr.frames ? spr.frames : 1;
1078 int32_t spd = spr.speed ? spr.speed : 1;
1079 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1080 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1081 }
1082 }
1083 21147337 return false;
1084 21147337 }
1085
1086 // Supplemental animation code that all derived classes should call
1087 // as a return value for animate().
1088 // Handles the death animation and returns true when enemy is finished.
1089 21531602 bool enemy::Dead(int32_t index)
1090 {
1091
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21529773 times.
21531602 if(immortal)
1092 {
1093 1829 dying = false;
1094 1829 return false;
1095 }
1096
2/2
✓ Branch 0 taken 449834 times.
✓ Branch 1 taken 21079939 times.
21529773 if(dying)
1097 {
1098
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 449833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
449834 if(deathexstate > -1 && deathexstate < 32)
1099 {
1100 1 setxmapflag(1<<deathexstate);
1101 1 deathexstate = -1;
1102 1 }
1103 449834 --clk2;
1104
1105
4/4
✓ Branch 0 taken 445139 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 21421 times.
✓ Branch 3 taken 2961 times.
449834 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1106
2/2
✓ Branch 0 taken 24382 times.
✓ Branch 1 taken 420757 times.
445139 && hp>-1000) // not killed by ringleader
1107 21421 death_sfx();
1108
1109
2/2
✓ Branch 0 taken 425254 times.
✓ Branch 1 taken 24580 times.
449834 if(clk2==0)
1110 {
1111
2/2
✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 406 times.
24580 if(flags&guy_neverret)
1112 406 never_return(index);
1113
1114
2/2
✓ Branch 0 taken 24523 times.
✓ Branch 1 taken 57 times.
24580 if(leader)
1115 57 kill_em_all();
1116
1117 24580 leave_item();
1118 24580 }
1119
1120 449834 stop_bgsfx(index);
1121 449834 return (clk2==0);
1122 }
1123
1124 21079939 return false;
1125 21531602 }
1126
1127 // Basic animation code that all derived classes should call.
1128 // The one with an index is the one that is called by
1129 // the guys sprite list; index is the enemy's index in the list.
1130 21147479 bool enemy::animate(int32_t index)
1131 {
1132
2/2
✓ Branch 0 taken 896465 times.
✓ Branch 1 taken 20251014 times.
21147479 if(sclk <= 0) hitdir = -1;
1133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21147479 times.
21147479 if(switch_hooked)
1134 {
1135 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1136 {
1137 //Run its script
1138 if (!didScriptThisFrame)
1139 {
1140 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1141 {
1142 return 0; //Avoid NULLPO if this object deleted itself
1143 }
1144 }
1145 }
1146 return false;
1147 }
1148
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21147477 times.
21147479 if(do_falling(index)) return true;
1149
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 21147337 times.
21147477 else if(fallclk)
1150 {
1151 //clks
1152
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
1153 60 --hclk;
1154
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
1155 --stunclk;
1156
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
1157 --frozenclock;
1158
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
1159 {
1160 Hero.setX(x);
1161 Hero.setY(y);
1162 Hero.fallCombo = fallCombo;
1163 Hero.fallclk = fallclk;
1164 hashero = false; //Let Hero go if falling
1165 }
1166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!didScriptThisFrame)
1167 {
1168 140 run_script(MODE_NORMAL);
1169 140 }
1170 140 return false;
1171 }
1172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21147337 times.
21147337 if(do_drowning(index)) return true;
1173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21147337 times.
21147337 else if(drownclk)
1174 {
1175 //clks
1176 if(hclk>0)
1177 --hclk;
1178 if(stunclk>0)
1179 --stunclk;
1180 if ( frozenclock > 0 )
1181 --frozenclock;
1182 if(hashero)
1183 {
1184 Hero.setX(x);
1185 Hero.setY(y);
1186 Hero.drownclk = drownclk;
1187 hashero = false; //Let Hero go if falling
1188 }
1189 if (!didScriptThisFrame)
1190 {
1191 run_script(MODE_NORMAL);
1192 }
1193 return false;
1194 }
1195 21147337 int32_t nx = real_x(x);
1196 21147337 int32_t ny = real_y(y);
1197
1198
4/4
✓ Branch 0 taken 15589655 times.
✓ Branch 1 taken 5557682 times.
✓ Branch 2 taken 3125946 times.
✓ Branch 3 taken 12463709 times.
21147337 if(ox!=nx || oy!=ny)
1199 {
1200 8683628 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1201 8683628 }
1202
1203 21147337 ox = nx;
1204 21147337 oy = ny;
1205
1206 // Maybe they fell off the bottom in sideview, or were moved by a script.
1207
1208 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1209
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21145508 times.
21147337 if ( immortal )
1210 {
1211 //skip, as it can go out of bounds, from immortality
1212 1829 }
1213
2/6
✓ Branch 0 taken 21145508 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21145508 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21145508 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1214 {
1215 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1216 }
1217
9/10
✓ Branch 0 taken 20749415 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 21144503 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 21114792 times.
✓ Branch 5 taken 29711 times.
✓ Branch 6 taken 21114792 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 21114756 times.
21145508 else if ( (OUTOFBOUNDS) )
1218 {
1219 30752 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1220 30752 }
1221 //fall down
1222
6/6
✓ Branch 0 taken 13962695 times.
✓ Branch 1 taken 7184642 times.
✓ Branch 2 taken 7025680 times.
✓ Branch 3 taken 14121657 times.
✓ Branch 4 taken 338067 times.
✓ Branch 5 taken 6687613 times.
21147337 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
1223 {
1224
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 6384039 times.
6687613 if(isSideViewGravity())
1225 {
1226
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1227 {
1228
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1229 {
1230 127235 bool willHitSVPlatform = false;
1231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1233
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1234 {
1235
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1236 {
1237 willHitSVPlatform = true;
1238 break;
1239 }
1240 127235 }
1241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1242 {
1243 y+=fall/100;
1244 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1245 do_fix(y, 16); //Fix to top of SV Ladder
1246 fall = 0;
1247 }
1248 else
1249 {
1250 127235 y+=fall/100;
1251
2/2
✓ Branch 0 taken 109427 times.
✓ Branch 1 taken 17808 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1252 109427 fall += (zinit.gravity2/100);
1253 }
1254 127235 }
1255 else
1256 {
1257
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
1258 {
1259 //y-=(int32_t)y%8; // Fix position
1260 267 do_fix(y, 8); //Fix position
1261 267 }
1262
1263 176339 fall = 0;
1264 }
1265 303574 }
1266 else
1267 {
1268 if(isOnSideviewPlatform())
1269 fall = 0;
1270 else
1271 {
1272 zfix fall_amnt = fall/100;
1273 bool hit = false;
1274 while(fall_amnt >= 1)
1275 {
1276 --fall_amnt;
1277 ++y;
1278 if(isOnSideviewPlatform())
1279 {
1280 y = y.getInt();
1281 fall_amnt = 0;
1282 hit = true;
1283 break;
1284 }
1285 }
1286 if(fall_amnt > 0)
1287 y += fall_amnt;
1288 if(fall_amnt < 0)
1289 {
1290 if(!movexy(0,fall_amnt,spw_none))
1291 hit = true;
1292 }
1293 if(hit)
1294 fall = 0;
1295 else if(fall <= (int32_t)zinit.terminalv)
1296 fall += (zinit.gravity2/100);
1297 }
1298 }
1299 303574 }
1300 else
1301 {
1302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6384039 times.
6384039 if (!(moveflags & FLAG_NO_FAKE_Z))
1303 {
1304
2/2
✓ Branch 0 taken 3219015 times.
✓ Branch 1 taken 3165024 times.
6384039 if(fakefall!=0)
1305 3165024 fakez-=(fakefall/100);
1306
1307
2/2
✓ Branch 0 taken 3165024 times.
✓ Branch 1 taken 3219015 times.
6384039 if(fakez<0)
1308 3165024 fakez = fakefall = 0;
1309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3219015 times.
3219015 else if(fakefall <= (int32_t)zinit.terminalv)
1310 3219015 fakefall += (zinit.gravity2/100);
1311
1312
5/6
✓ Branch 0 taken 6384039 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3219015 times.
✓ Branch 3 taken 3165024 times.
✓ Branch 4 taken 3173265 times.
✓ Branch 5 taken 45750 times.
6384039 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1313 6384039 }
1314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6384039 times.
6384039 if (!(moveflags & FLAG_NO_REAL_Z))
1315 {
1316
2/2
✓ Branch 0 taken 3485527 times.
✓ Branch 1 taken 2898512 times.
6384039 if(fall!=0)
1317 2898512 z-=(fall/100);
1318
1319
2/2
✓ Branch 0 taken 2892688 times.
✓ Branch 1 taken 3491351 times.
6384039 if(z<0)
1320 2892688 z = fall = 0;
1321
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 3486707 times.
3491351 else if(fall <= (int32_t)zinit.terminalv)
1322 3486707 fall += (zinit.gravity2/100);
1323
1324
6/6
✓ Branch 0 taken 6378118 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 3485430 times.
✓ Branch 3 taken 2892688 times.
✓ Branch 4 taken 3439680 times.
✓ Branch 5 taken 45750 times.
6384039 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1325 6384039 }
1326
1327 }
1328 6687613 }
1329
4/4
✓ Branch 0 taken 20751244 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 11941970 times.
✓ Branch 3 taken 18003392 times.
21147337 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
1330 {
1331
8/10
✓ Branch 0 taken 6009035 times.
✓ Branch 1 taken 11994357 times.
✓ Branch 2 taken 6002050 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 6002050 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6009035 times.
✓ Branch 8 taken 6002050 times.
✓ Branch 9 taken 6002050 times.
18003392 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1332 {
1333 6002050 fallCombo = check_pits();
1334 6002050 }
1335 30007492 }
1336
3/4
✓ Branch 0 taken 20751244 times.
✓ Branch 1 taken 4802131 times.
✓ Branch 2 taken 20751244 times.
✗ Branch 3 not taken.
18356841 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
1337 {
1338 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1339 {
1340 drownCombo = check_water();
1341 }
1342 }
1343
1344 25553375 runKnockback(); //scripted knockback handling
1345
1346 // clk is incremented here
1347
2/2
✓ Branch 0 taken 24417538 times.
✓ Branch 1 taken 1135837 times.
25553375 if(++clk >= frate)
1348 1135837 clk=0;
1349
1350 // hit and death handling
1351
2/2
✓ Branch 0 taken 24869644 times.
✓ Branch 1 taken 683731 times.
25553375 if(hclk>0)
1352 683731 --hclk;
1353
1354
2/2
✓ Branch 0 taken 25120983 times.
✓ Branch 1 taken 432392 times.
25553375 if(stunclk>0)
1355 432392 --stunclk;
1356
1/2
✓ Branch 0 taken 25553375 times.
✗ Branch 1 not taken.
25553375 if ( frozenclock > 0 )
1357 --frozenclock;
1358
1359
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 25546373 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
25553375 if(ceiling && z <= 0 && fakez <= 0)
1360 55 ceiling = false;
1361
1362 25553375 try_death();
1363
1364 25553375 scored=false;
1365
1366 25553375 ++c_clk;
1367
1368 //Run its script
1369
2/2
✓ Branch 0 taken 4408078 times.
✓ Branch 1 taken 21147337 times.
25553375 if (!didScriptThisFrame)
1370 {
1371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21147337 times.
21147337 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1372 {
1373 return 0; //Avoid NULLPO if this object deleted itself
1374 }
1375 21147337 }
1376
1377 // returns true when enemy is defeated
1378 25555415 return Dead(index);
1379 25555557 }
1380
1381 21571470 bool enemy::setSolid(bool set)
1382 {
1383
1/2
✓ Branch 0 taken 21571470 times.
✗ Branch 1 not taken.
21571470 bool actual = set && !isSubmerged();
1384 21571470 bool ret = solid_object::setSolid(actual);
1385 21571470 solid = set;
1386 21571470 return ret;
1387 }
1388 void enemy::doContactDamage(int32_t hdir)
1389 {
1390 Hero.hithero(guys.find(this), hdir);
1391 }
1392
1393 3278 void enemy::solid_push(solid_object *obj)
1394 {
1395
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 if(obj == this) return; //can't push self
1396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
1397 3278 zfix dx, dy;
1398 3278 int32_t hdir = -1;
1399 3278 solid_push_int(obj,dx,dy,hdir);
1400
1401
2/4
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
3278 if(!dx && !dy) return;
1402
1403 bool t = obj->getTempNonsolid();
1404 obj->setTempNonsolid(true);
1405
1406 int32_t ydir = dy > 0 ? down : up;
1407 int32_t xdir = dx > 0 ? right : left;
1408
1409 auto special = isflier(id) ? spw_floater : spw_none;
1410 if(!movexy(dx,dy,special,true,true))
1411 {
1412 //Crushed?
1413 }
1414
1415 obj->setTempNonsolid(t);
1416 3278 }
1417 3278 bool enemy::is_unpushable() const
1418 {
1419 3278 return isSubmerged();
1420 }
1421 3278 bool enemy::sideview_mode() const
1422 {
1423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3278 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
1424 }
1425
1426 2559 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1427 {
1428 2559 int32_t yg = (special==spw_floater)?8:0;
1429 2559 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1430
1431
8/10
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 613 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 613 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1948 times.
✓ Branch 9 taken 2561 times.
2559 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1432 3894 return true;
1433
1434 2561 bool isInDungeon = isdungeon();
1435
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2445 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
2561 if(isInDungeon || special==spw_wizzrobe)
1436 {
1437
7/8
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 1462 times.
✓ Branch 6 taken 495 times.
✗ Branch 7 not taken.
2445 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1438 983 return true;
1439
1440
7/8
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 488 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 488 times.
✗ Branch 7 not taken.
1462 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1441
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
976 if(special!=spw_door) // walk in door way
1442 return true;
1443 488 }
1444
1445
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
604 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
1446 {
1447
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1448
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1449 return true;
1450 62 }
1451
1452
1/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604 switch(special)
1453 {
1454 case spw_clipbottomright:
1455 if(dy>=128 || dx>=208) return true;
1456 break;
1457 case spw_clipright:
1458 break; //if(x>=208) return true; break;
1459
1460 case spw_wizzrobe: // fall through
1461 case spw_floater: // Special case for fliers and wizzrobes - hack!
1462 {
1463
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 488 times.
604 if(isInDungeon)
1464 {
1465
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dy < 32-yg || dy >= 144) return true;
1466
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dx < 32 || dx >= 224) return true;
1467 488 }
1468 604 return false;
1469 }
1470 }
1471
1472 dx&=(special==spw_halfstep)?(~7):(~15);
1473 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1474
1475 if(special==spw_water)
1476 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1477
1478 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1479 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1480 613 }
1481
1482 5149 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1483 {
1484 5149 bool kb = false;
1485 5149 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1486
1487
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
✓ Branch 2 taken 5041 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 5149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5149 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5149 times.
5149 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1488 return true;
1489
1490
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 715 times.
5149 if(isdungeon())
1491 {
1492
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dy<32) || (dy>=144))
1493 return true;
1494
1495
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dx<32) || (dx>=224))
1496 return true;
1497 715 }
1498
1499
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
5149 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
1500 {
1501
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
10298 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1502
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
5149 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1503 return true;
1504 5149 }
1505
1506
1/2
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
5149 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1507 {
1508
3/4
✓ Branch 0 taken 1489 times.
✓ Branch 1 taken 3660 times.
✓ Branch 2 taken 1489 times.
✗ Branch 3 not taken.
6638 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1489 times.
1489 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1510 }
1511 else
1512 {
1513 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1514 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1515 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1516 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1517 }
1518 5149 }
1519
1520 19031295 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1521 {
1522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19031295 times.
19031295 if(moveflags & FLAG_USE_NEW_MOVEMENT)
1523 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1524 19031295 int32_t yg = (special==spw_floater)?8:0;
1525 19031295 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1526
2/2
✓ Branch 0 taken 1960671 times.
✓ Branch 1 taken 17070624 times.
19031295 switch(dir)
1527 {
1528 case l_down:
1529 case r_down:
1530 case down:
1531 case 11: //r_down
1532 case 12: //down
1533 case 13: //l_down
1534 {
1535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1960671 times.
1960671 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1536 {
1537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1960671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1960671 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1538 {
1539 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1540 dy += zc_max(hit_height-16,0);
1541 }
1542 1960671 }
1543 1960671 break;
1544 }
1545 }
1546
2/2
✓ Branch 0 taken 1972901 times.
✓ Branch 1 taken 17058394 times.
19031295 switch(dir)
1547 {
1548 case r_up:
1549 case r_down:
1550 case right:
1551 case 9: //r_up
1552 case 10: //right
1553 case 11: //r_down
1554 {
1555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1972901 times.
1972901 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1556 {
1557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1972901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1972901 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1558 {
1559 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1560 dx += zc_max(hit_width-16,0);
1561 }
1562 1972901 }
1563 1972901 break;
1564 }
1565 }
1566 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1567
1568
10/10
✓ Branch 0 taken 13732205 times.
✓ Branch 1 taken 5299090 times.
✓ Branch 2 taken 4195534 times.
✓ Branch 3 taken 1103556 times.
✓ Branch 4 taken 5287001 times.
✓ Branch 5 taken 12089 times.
✓ Branch 6 taken 5273982 times.
✓ Branch 7 taken 13019 times.
✓ Branch 8 taken 13759069 times.
✓ Branch 9 taken 19031791 times.
19031295 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1569 27516382 return true;
1570
1571 19031791 bool isInDungeon = isdungeon();
1572
4/4
✓ Branch 0 taken 1581552 times.
✓ Branch 1 taken 17450239 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 1580429 times.
19031791 if(isInDungeon || special==spw_wizzrobe)
1573 {
1574
8/8
✓ Branch 0 taken 3601717 times.
✓ Branch 1 taken 13849645 times.
✓ Branch 2 taken 3471583 times.
✓ Branch 3 taken 130134 times.
✓ Branch 4 taken 3560656 times.
✓ Branch 5 taken 10419123 times.
✓ Branch 6 taken 3560642 times.
✓ Branch 7 taken 14 times.
17451362 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1575 7032225 return true;
1576
1577
8/8
✓ Branch 0 taken 3512677 times.
✓ Branch 1 taken 6906460 times.
✓ Branch 2 taken 3413625 times.
✓ Branch 3 taken 99052 times.
✓ Branch 4 taken 3480646 times.
✓ Branch 5 taken 3524866 times.
✓ Branch 6 taken 3480643 times.
✓ Branch 7 taken 3 times.
10419137 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1578
2/2
✓ Branch 0 taken 66979 times.
✓ Branch 1 taken 39 times.
6894268 if(special!=spw_door) // walk in door way
1579 66979 return true;
1580 3524908 }
1581
1582
6/6
✓ Branch 0 taken 2212757 times.
✓ Branch 1 taken 2892580 times.
✓ Branch 2 taken 427539 times.
✓ Branch 3 taken 1785218 times.
✓ Branch 4 taken 34289 times.
✓ Branch 5 taken 393250 times.
5105337 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
1583 {
1584
3/4
✓ Branch 0 taken 2178461 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2178461 times.
4356929 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1585
2/4
✓ Branch 0 taken 2178461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178461 times.
✗ Branch 3 not taken.
2178461 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1586 7 return true;
1587 2178461 }
1588
1589
4/4
✓ Branch 0 taken 4093655 times.
✓ Branch 1 taken 1008077 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3553 times.
5105330 switch(special)
1590 {
1591 case spw_clipbottomright:
1592
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
1593 45 break;
1594 case spw_clipright:
1595 3553 break; //if(input_x>=208) return true; break;
1596
1597 case spw_wizzrobe: // fall through
1598 case spw_floater: // Special case for fliers and wizzrobes - hack!
1599 {
1600
2/2
✓ Branch 0 taken 1101316 times.
✓ Branch 1 taken 2992339 times.
4093655 if(isInDungeon)
1601 {
1602
3/4
✓ Branch 0 taken 2992328 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2992328 times.
2992339 if(dy < 32-yg || dy >= 144) return true;
1603
3/4
✓ Branch 0 taken 2991477 times.
✓ Branch 1 taken 851 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2991477 times.
2992328 if(dx < 32 || dx >= 224) return true;
1604 2991477 }
1605 4092793 return false;
1606 }
1607 }
1608
1609 1011675 dx&=(special==spw_halfstep)?(~7):(~15);
1610
2/2
✓ Branch 0 taken 224029 times.
✓ Branch 1 taken 787646 times.
1011675 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1611
1612
2/2
✓ Branch 0 taken 117322 times.
✓ Branch 1 taken 894353 times.
1011675 if(special==spw_water)
1613
2/2
✓ Branch 0 taken 8245 times.
✓ Branch 1 taken 109077 times.
117322 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1614
1615
2/2
✓ Branch 0 taken 892220 times.
✓ Branch 1 taken 2133 times.
894353 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1616 {
1617
4/4
✓ Branch 0 taken 666298 times.
✓ Branch 1 taken 225922 times.
✓ Branch 2 taken 660380 times.
✓ Branch 3 taken 5918 times.
1552600 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1618
2/2
✓ Branch 0 taken 2852 times.
✓ Branch 1 taken 657528 times.
660380 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1619 }
1620 else
1621 {
1622
4/4
✓ Branch 0 taken 1578 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 1566 times.
✓ Branch 3 taken 12 times.
3699 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1623
3/4
✓ Branch 0 taken 1558 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1558 times.
✗ Branch 3 not taken.
1566 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1624
3/4
✓ Branch 0 taken 1524 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1524 times.
✗ Branch 3 not taken.
1558 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1524 times.
1524 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1626 }
1627 5313977 }
1628
1629 383430 bool enemy::isOnSideviewPlatform()
1630 {
1631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1633
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1635
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1636 {
1637
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1638
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1640 47357 }
1641 168001 return false;
1642 383430 }
1643
1644 // Stops playing the given sound only if there are no enemies left to play it
1645 451658 void enemy::stop_bgsfx(int32_t index)
1646 {
1647
2/2
✓ Branch 0 taken 441954 times.
✓ Branch 1 taken 9704 times.
451658 if(bgsfx<=0)
1648 441954 return;
1649
1650 // Look for other enemies with the same bgsfx
1651
2/2
✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 5718 times.
45025 for(int32_t i=0; i<guys.Count(); i++)
1652 {
1653
4/4
✓ Branch 0 taken 32357 times.
✓ Branch 1 taken 6950 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 28371 times.
39307 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1654 3986 return;
1655 35321 }
1656
1657 5718 stop_sfx(bgsfx);
1658 451658 }
1659
1660
1661 // to allow for different sfx on defeating enemy
1662 21658 void enemy::death_sfx()
1663 {
1664
2/2
✓ Branch 0 taken 21634 times.
✓ Branch 1 taken 24 times.
21658 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1665 21658 }
1666
1667 void enemy::move(zfix dx,zfix dy)
1668 {
1669 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1670 {
1671 switch(family)
1672 {
1673 case eeFIRE:
1674 case eeOTHER:
1675 return;
1676 default: break;
1677 }
1678 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1679 }
1680 */
1681 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
1682 {
1683 x+=dx;
1684 y+=dy;
1685 }
1686 }
1687
1688 10384163 void enemy::move(zfix s)
1689 {
1690 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1691 {
1692 switch(family)
1693 {
1694 case eeFIRE:
1695 case eeOTHER:
1696 return;
1697 default: break;
1698 }
1699 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1700 }*/
1701
9/10
✓ Branch 0 taken 10384124 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 10304362 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
10384163 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
1702 {
1703 10383269 sprite::move(s);
1704 10383269 }
1705 10384163 }
1706
1707 24760 void enemy::leave_item()
1708 {
1709 24760 int32_t drop_item = select_dropitem(item_set, x, y);
1710 24760 int32_t thedropset = item_set;
1711
1712 24760 std::vector<int32_t> &ev = FFCore.eventData;
1713 24760 ev.clear();
1714 24760 ev.push_back(getUID());
1715 24760 ev.push_back(drop_item*10000);
1716 24760 ev.push_back(thedropset*10000);
1717
1718 24760 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1719 24760 drop_item = vbound(ev[1] / 10000,-2,255);
1720 24760 thedropset = ev[2] / 10000;
1721 24760 ev.clear();
1722
1/2
✓ Branch 0 taken 24760 times.
✗ Branch 1 not taken.
24760 if(drop_item == -2)
1723 {
1724 drop_item = select_dropitem(thedropset,x,y);
1725 }
1726
1727
6/6
✓ Branch 0 taken 9759 times.
✓ Branch 1 taken 15001 times.
✓ Branch 2 taken 563 times.
✓ Branch 3 taken 9196 times.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 414 times.
24760 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1728 {
1729 item* itm;
1730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9610 times.
9610 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1731 {
1732 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1733 }
1734 else
1735 {
1736
8/14
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 8174 times.
✓ Branch 2 taken 1436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1436 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1436 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1436 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1436 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1436 times.
✗ Branch 13 not taken.
9610 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1737
4/8
✓ Branch 0 taken 8174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8174 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8174 times.
✗ Branch 7 not taken.
8174 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1738 }
1739 9610 itm->from_dropset = thedropset;
1740 9610 items.add(itm);
1741
1742 9610 ev.push_back(getUID());
1743 9610 ev.push_back(itm->getUID());
1744
1745 9610 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1746 9610 ev.clear();
1747 9610 }
1748 24760 }
1749
1750 // auomatically kill off enemy (for rooms with ringleaders)
1751 344 void enemy::kickbucket()
1752 {
1753
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 32 times.
344 if(!superman)
1754 312 hp=-1000; // don't call death_sfx()
1755 344 }
1756
1757 3278 bool enemy::isSubmerged() const
1758 {
1759 3278 return submerged;
1760 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1761 }
1762
1763 17408 void enemy::FireBreath(bool seekhero)
1764 {
1765
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(wpn==wNone)
1766 return;
1767
1768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17408 times.
17408 if(wpn==ewFireTrail)
1769 {
1770 dmisc1 = e1tEACHTILE;
1771 FireWeapon();
1772 return;
1773 }
1774
1775 17408 float fire_angle=0.0;
1776 17408 int32_t wx=0, wy=0, wdir=dir;
1777
1778
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 if(!seekhero)
1779 {
1780
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
1781 {
1782 case down:
1783 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1784 3038 wx=x;
1785 3038 wy=y+8;
1786 3038 break;
1787
1788 case -1:
1789 case up:
1790 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1791 3271 wx=x;
1792 3271 wy=y-8;
1793 3271 break;
1794
1795 case left:
1796 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1797 5264 wx=x-8;
1798 5264 wy=y;
1799 5264 break;
1800
1801 case right:
1802 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1803 4131 wx=x+8;
1804 4131 wy=y;
1805 4131 break;
1806 }
1807
1808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
1809 {
1810
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
1812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
1813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
1814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
1815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
1816
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
1817
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
1818 15704 }
1819 15704 }
1820 else
1821 {
1822 1704 wx = x;
1823 1704 wy = y;
1824 }
1825
1826
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1827 17408 sfx(wpnsfx(wpn),pan(int32_t(x)));
1828
1829 17408 int32_t i=Ewpns.Count()-1;
1830 17408 weapon *ew = (weapon*)(Ewpns.spr(i));
1831 17408 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1832
1833
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1704 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17408 if(!seekhero && (zc_oldrand()&4))
1834 {
1835 7874 ew->angular=true;
1836 7874 ew->angle=fire_angle;
1837 7874 }
1838
1839
4/4
✓ Branch 0 taken 17351 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 17034 times.
17408 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1840 {
1841 17034 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17034 times.
17034 if ( ew->do_animation ) ew->tile+=ew->aframe;
1843 17034 }
1844
1845
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 543348 times.
560756 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1846 {
1847 543348 Ewpns.swap(j,j-1);
1848 543348 }
1849 17408 }
1850
1851 28308 void enemy::FireWeapon()
1852 {
1853 /*
1854 * Type:
1855 * 0x01: Boss fireball
1856 * 0x02: Seeks Hero
1857 * 0x04: Fast projectile
1858 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1859 */
1860
1861
2/2
✓ Branch 0 taken 28298 times.
✓ Branch 1 taken 10 times.
28308 if (wpn < 1) return;
1862
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
28298 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1863 return;
1864
1865
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28298 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1866 dmisc1 = e1tEACHTILE;
1867
1868 28298 int32_t xoff = 0;
1869 28298 int32_t yoff = 0;
1870
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1871 {
1872 xoff += (hit_width/2)-8;
1873 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1874 }
1875
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1876 {
1877 yoff += (hit_height/2)-8;
1878 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1879 }
1880
1881
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 26887 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28298 switch(dmisc1)
1882 {
1883 case e1t5SHOTS: //BS-Aquamentus
1884 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1885 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1886 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1887 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1888
1889 [[fallthrough]];
1890 case e1t3SHOTSFAST:
1891 case e1t3SHOTS: //Aquamentus
1892
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1893 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1894
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1895 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1896
1897 [[fallthrough]];
1898 default:
1899
11/20
✓ Branch 0 taken 27300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 27300 times.
✓ Branch 12 taken 27300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11345 times.
✓ Branch 15 taken 15955 times.
✓ Branch 16 taken 27300 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27300 times.
✗ Branch 19 not taken.
27300 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1900 27300 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1901 27300 sfx(wpnsfx(wpn),pan(int32_t(x)));
1902 27300 break;
1903
1904 case e1tSLANT:
1905 {
1906 409 int32_t slant = 0;
1907
1908
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1909 236 slant = left;
1910
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1911 112 slant = right;
1912
1913
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1914 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
1916 319 break;
1917 }
1918
1919 case e1t8SHOTS: //Fire Wizzrobe
1920 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1921 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1922 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1923 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1924 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1925 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1926 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1927 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1928 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1929 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1930 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1931 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1932
1933 [[fallthrough]];
1934 case e1t4SHOTS: //Stalfos 3
1935
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1936 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1937 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1938
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1939 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1940 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1941
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1942 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1943 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1944
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1945 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1946 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1947 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
1948 589 break;
1949
1950 case e1tSUMMON: // Bat Wizzrobe
1951 {
1952 //al_trace("Summon Bats\n");
1953 //zprint2("Summon Bats\n");
1954 if(dmisc4==0) break; // Summon 0
1955
1956 int32_t bc=0;
1957
1958 for(int32_t gc=0; gc<guys.Count(); gc++)
1959 {
1960 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1961 {
1962 ++bc;
1963 }
1964 }
1965
1966 if(bc<=40) // Not too many enemies
1967 {
1968 int32_t kids = guys.Count();
1969 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1970
1971 for(int32_t i=0; i<bats; i++)
1972 {
1973 //zprint2("summon\n");
1974 //al_trace("summon\n");
1975 if(addchild(x,y,dmisc3,-10, this->script_UID))
1976 {
1977 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1978 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
1979 //zprint2("Summoner Script UID: %d\n",this->script_UID);
1980
1981 }
1982 }
1983
1984 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1985 }
1986
1987 break;
1988 }
1989
1990 case e1tSUMMONLAYER: // Summoner
1991 {
1992 if(count_layer_enemies()==0)
1993 {
1994 break;
1995 }
1996
1997 int32_t kids = guys.Count();
1998
1999 if(kids<40)
2000 {
2001 int32_t newguys=(zc_oldrand()%3)+1;
2002 bool summoned=false;
2003
2004 for(int32_t i=0; i<newguys; i++)
2005 {
2006 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
2007 int32_t x2=0;
2008 int32_t y2=0;
2009
2010 for(int32_t k=0; k<20; ++k)
2011 {
2012 x2=16*((zc_oldrand()%12)+2);
2013 y2=16*((zc_oldrand()%7)+2);
2014
2015 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2016 {
2017 //zprint2("summon\n");
2018 //al_trace("summon\n");
2019 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2020 {
2021 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2022 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
2023 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
2024 {
2025 ((enemy*)guys.spr(kids+i))->fakez = 64;
2026 ((enemy*)guys.spr(kids+i))->z = 0;
2027 }
2028 }
2029
2030 summoned=true;
2031 break;
2032 }
2033 }
2034 }
2035
2036 if(summoned)
2037 {
2038 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2039 }
2040 }
2041
2042 break;
2043 }
2044 }
2045 28218 }
2046
2047
2048 // Hit the shield(s)?
2049 // Apparently, this function is only used for hookshots...
2050 398 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2051 {
2052
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
398 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2053 106 return false;
2054
2055 292 bool ret = false;
2056
2057 // TODO: There must be some bitwise operations that can simplify this...
2058
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
292 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
2059
9/12
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
155 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
2060
2061
11/14
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 101 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 13 not taken.
300 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
2062
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 141 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
185 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
2063
2064 300 return ret;
2065 406 }
2066
2067
2068 //! Weapon Editor for 2.6
2069 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2070
2071
2072 //converts a wqeapon ID to its defence index.
2073 73090 int32_t weaponToDefence(int32_t wid)
2074 {
2075
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32485 times.
✓ Branch 3 taken 6764 times.
✓ Branch 4 taken 18964 times.
✓ Branch 5 taken 702 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1549 times.
✓ Branch 10 taken 7171 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 1166 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 866 times.
✓ Branch 21 taken 406 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 325 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 993 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
73090 switch(wid)
2076 {
2077 case wNone: return -1;
2078 32485 case wSword: return edefSWORD;
2079 6764 case wBeam: return edefBEAM;
2080 18964 case wBrang: return edefBRANG;
2081 702 case wBomb: return edefBOMB;
2082 28 case wSBomb: return edefSBOMB;
2083 48 case wLitBomb: return edefBOMB;
2084 case wLitSBomb: return edefSBOMB;
2085 1549 case wArrow: return edefARROW;
2086 7171 case wFire: return edefFIRE;
2087 case wWhistle:
2088 {
2089 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
2090 return edefWhistle;
2091 }
2092 case wBait: return edefBAIT;
2093 163 case wWand: return edefWAND;
2094 1166 case wMagic: return edefMAGIC;
2095 case wCatching: return -1;
2096 case wWind: return edefWIND;
2097 322 case wRefMagic: return edefREFMAGIC;
2098 920 case wRefFireball: return edefREFBALL;
2099 case wRefRock: return edefREFROCK;
2100 866 case wHammer: return edefHAMMER;
2101 406 case wHookshot: return edefHOOKSHOT;
2102 118 case wHSHandle: return edefHOOKSHOT;
2103 case wHSChain: return edefHOOKSHOT;
2104 case wSSparkle: return edefSPARKLE;
2105 325 case wFSparkle: return edefSPARKLE;
2106 case wSmack: return -1; // is this the candle object?
2107 case wPhantom: return -1; //engine created visual effects.
2108 case wCByrna: return edefBYRNA;
2109 11 case wRefBeam: return edefREFBEAM;
2110 case wStomp: return edefSTOMP;
2111 case wScript1: return edefSCRIPT01;
2112 case wScript2: return edefSCRIPT02;
2113 12 case wScript3: return edefSCRIPT03;
2114 77 case wScript4: return edefSCRIPT04;
2115 case wScript5: return edefSCRIPT05;
2116 case wScript6: return edefSCRIPT06;
2117 case wScript7: return edefSCRIPT07;
2118 case wScript8: return edefSCRIPT08;
2119 case wScript9: return edefSCRIPT09;
2120 993 case wScript10: return edefSCRIPT10;
2121 case wIce: return edefICE;
2122 case wSound: return edefSONIC;
2123 case wThrown: return edefTHROWN;
2124 //case wPot: return edefPOT;
2125 // case wLitZap: return edefELECTRIC;
2126 // case wZ3Sword: return edefZ3SWORD;
2127 // case wLASWord: return edefLASWORD;
2128 // case wSpinAttk: return edefSPINATTK;
2129 // case wShield: return edefSHIELD;
2130 // case wTrowel: return edefTROWEL;
2131
2132 default: return -1;
2133 }
2134 73090 }
2135
2136 73090 int32_t getDefType(weapon *w)
2137 {
2138 73090 int32_t id = getWeaponID(w);
2139 73090 int32_t edef = weaponToDefence(id);
2140
2/2
✓ Branch 0 taken 72566 times.
✓ Branch 1 taken 524 times.
73090 if(edef == edefHOOKSHOT)
2141 {
2142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(w->family_class == itype_switchhook)
2143 return edefSwitchHook;
2144 524 }
2145 73090 return edef;
2146 73090 }
2147
2148 126810 int32_t getWeaponID(weapon *w)
2149 {
2150 126810 int32_t usewpn = w->useweapon;
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126810 times.
126810 return (usewpn > 0) ? usewpn : w->id;
2152 }
2153
2154 73090 int32_t enemy::resolveEnemyDefence(weapon *w)
2155 {
2156 //sword edef is 9, but we're reading it at 0
2157 //,
2158 73090 int32_t weapondef = 0;
2159 73090 int32_t wdeftype = getDefType(w);
2160 73090 int32_t usedef = w->usedefence;
2161
2162
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
73090 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2163 {
2164 weapondef = usedef*-1;
2165 }
2166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
73090 else if(unsigned(wdeftype) < edefLAST255)
2167 {
2168 73090 weapondef = wdeftype;
2169 73090 }
2170 73090 return weapondef;
2171 }
2172
2173 79108 byte get_def_ignrflag(int32_t edef)
2174 {
2175
3/3
✓ Branch 0 taken 66047 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 10732 times.
79108 switch(edef)
2176 {
2177 case edIGNORE:
2178 case edIGNOREL1:
2179 case edSTUNORIGNORE:
2180 10732 return WPNUNB_IGNR;
2181 case edSTUNORCHINK:
2182 case edCHINK:
2183 case edCHINKL1:
2184 case edCHINKL2:
2185 case edCHINKL4:
2186 case edCHINKL6:
2187 case edCHINKL8:
2188 case edCHINKL10:
2189 case edLEVELCHINK2:
2190 case edLEVELCHINK3:
2191 case edLEVELCHINK4:
2192 case edLEVELCHINK5:
2193 2329 return WPNUNB_BLOCK;
2194 }
2195 66047 return 0;
2196 79108 }
2197
2198 79108 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2199 {
2200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79108 times.
79108 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2201 switch(edef)
2202 {
2203 case edIGNORE:
2204 case edIGNOREL1:
2205 case edCHINK:
2206 case edCHINKL1:
2207 case edCHINKL2:
2208 case edCHINKL4:
2209 case edCHINKL6:
2210 case edCHINKL8:
2211 case edCHINKL10:
2212 case edLEVELCHINK2:
2213 case edLEVELCHINK3:
2214 case edLEVELCHINK4:
2215 case edLEVELCHINK5:
2216 return edNORMAL;
2217 case edSTUNORIGNORE:
2218 case edSTUNORCHINK:
2219 return edSTUNONLY;
2220 }
2221 return edef;
2222 79108 }
2223
2224 // Do we do damage?
2225 // 0: takehit returns 0
2226 // 1: takehit returns 1
2227 // -1: do damage
2228 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2229 72097 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2230 {
2231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(switch_hooked) return 0;
2232 72097 int32_t tempx = x;
2233 72097 int32_t tempy = y;
2234 72097 int32_t the_defence = 0;
2235
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2236 {
2237 the_defence = edef*-1; //A specific defence type.
2238 }
2239 72097 else the_defence = defense[edef];
2240
2241 72097 the_defence = conv_edef_unblockable(the_defence, unblockable);
2242
2243
3/4
✓ Branch 0 taken 4350 times.
✓ Branch 1 taken 67747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4350 times.
72097 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2244 {
2245
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4343 times.
✓ Branch 2 taken 7 times.
4350 switch(the_defence)
2246 {
2247 case edIGNORE:
2248 7 return 0;
2249 case edIGNOREL1:
2250 case edSTUNORIGNORE:
2251 if(*power <= 0)
2252 return 0;
2253 }
2254 4343 sfx(WAV_CHINK,pan(int32_t(x)));
2255 4343 return 1;
2256 }
2257
2258 67747 int32_t new_id = id;
2259 67747 int32_t effect_type = dmisc15;
2260 67747 int32_t delay_timer = 90;
2261 67747 enemy *gleeok = NULL;
2262 67747 enemy *ptra = NULL;
2263 67747 int32_t c = 0;
2264
2265
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 902 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 199 times.
✓ Branch 13 taken 9312 times.
✓ Branch 14 taken 173 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1789 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 53312 times.
67747 switch(the_defence)
2266 {
2267 case edREPLACE:
2268 {
2269 sclk = 0;
2270 if ( dmisc16 > 0 ) new_id = dmisc16;
2271 else new_id = id+1;
2272 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2273 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2274 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2275
2276 //Z_scripterrlog("new id is %d\n", new_id);
2277 switch(guysbuf[new_id&0xFFF].family)
2278 {
2279 //Fixme: possible enemy memory leak. (minor)
2280 case eeWALK:
2281 {
2282 enemy *e = new eStalfos(x,y,new_id,clk);
2283 guys.add(e);
2284 }
2285 break;
2286
2287 case eeLEV:
2288 {
2289 enemy *e = new eLeever(x,y,new_id,clk);
2290 guys.add(e);
2291 }
2292 break;
2293
2294 case eeTEK:
2295 {
2296 enemy *e = new eTektite(x,y,new_id,clk);
2297 guys.add(e);
2298 }
2299 break;
2300
2301 case eePEAHAT:
2302 {
2303 enemy *e = new ePeahat(x,y,new_id,clk);
2304 guys.add(e);
2305 }
2306 break;
2307
2308 case eeZORA:
2309 {
2310 enemy *e = new eZora(x,y,new_id,clk);
2311 guys.add(e);
2312 }
2313 break;
2314
2315 case eeGHINI:
2316 {
2317 enemy *e = new eGhini(x,y,new_id,clk);
2318 guys.add(e);
2319 }
2320 break;
2321
2322 case eeKEESE:
2323 {
2324 enemy *e = new eKeese(x,y,new_id,clk);
2325 guys.add(e);
2326 }
2327 break;
2328
2329 case eeWIZZ:
2330 {
2331 enemy *e = new eWizzrobe(x,y,new_id,clk);
2332 guys.add(e);
2333 }
2334 break;
2335
2336 case eePROJECTILE:
2337 {
2338 enemy *e = new eProjectile(x,y,new_id,clk);
2339 guys.add(e);
2340 }
2341 break;
2342
2343 case eeWALLM:
2344 {
2345 enemy *e = new eWallM(x,y,new_id,clk);
2346 guys.add(e);
2347 }
2348 break;
2349
2350 case eeAQUA:
2351 {
2352 enemy *e = new eAquamentus(x,y,new_id,clk);
2353 guys.add(e);
2354 e->x = x;
2355 e->y = y;
2356 }
2357 break;
2358
2359 case eeMOLD:
2360 {
2361 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
2362 guys.add(e);
2363 e->x = x;
2364 e->y = y;
2365 }
2366 break;
2367
2368 case eeMANHAN:
2369 {
2370 enemy *e = new eManhandla(x,y,new_id,clk);
2371 guys.add(e);
2372 e->x = x;
2373 e->y = y;
2374 }
2375 break;
2376
2377 case eeGLEEOK:
2378 {
2379 *power = 0;
2380 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
2381 guys.add(gleeok);
2382 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2383 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2384 new_id &= 0xFFF;
2385 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2386 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2387 for(int32_t i=0; i<head_cnt; i++)
2388 {
2389 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2390 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2391 {
2392 al_trace("Gleeok head %d could not be created!\n",i+1);
2393
2394 for(int32_t j=0; j<i+1; j++)
2395 {
2396 guys.del(guys.Count()-1);
2397 }
2398
2399 break;
2400 }
2401 else
2402 {
2403 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2404 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2405 }
2406
2407 c-=guysbuf[new_id].misc4;
2408 //gleeok->x = x;
2409 //gleeok->y = y;
2410 //gleeok = e;
2411 }
2412 return 1;
2413 }
2414
2415 case eeGHOMA:
2416 {
2417 enemy *e = new eGohma(x,y,new_id,clk);
2418 guys.add(e);
2419 e->x = x;
2420 e->y = y;
2421 }
2422 break;
2423
2424 case eeLANM:
2425 {
2426 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
2427 guys.add(e);
2428 e->x = x;
2429 e->y = y;
2430 }
2431 break;
2432
2433 case eeGANON:
2434 {
2435 enemy *e = new eGanon(x,y,new_id,clk);
2436 guys.add(e);
2437 e->x = x;
2438 e->y = y;
2439 }
2440 break;
2441
2442 case eeFAIRY:
2443 {
2444 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2445 guys.add(e);
2446 e->x = x;
2447 e->y = y;
2448 }
2449 break;
2450
2451 case eeFIRE:
2452 {
2453 enemy *e = new eFire(x,y,new_id,clk);
2454 guys.add(e);
2455 e->x = x;
2456 e->y = y;
2457 }
2458 break;
2459
2460 case eeOTHER:
2461 {
2462 enemy *e = new eOther(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 case eeSPINTILE:
2470 {
2471 enemy *e = new eSpinTile(x,y,new_id,clk);
2472 guys.add(e);
2473 e->x = x;
2474 e->y = y;
2475 }
2476 break;
2477
2478 // and these enemies use the misc10/misc2 value
2479 case eeROCK:
2480 {
2481 switch(guysbuf[new_id&0xFFF].misc10)
2482 {
2483 case 1:
2484 {
2485 enemy *e = new eBoulder(x,y,new_id,clk);
2486 guys.add(e);
2487 e->x = x;
2488 e->y = y;
2489 }
2490 break;
2491
2492 case 0:
2493 default:
2494 {
2495 enemy *e = new eRock(x,y,new_id,clk);
2496 guys.add(e);
2497 e->x = x;
2498 e->y = y;
2499 }
2500 break;
2501 }
2502
2503 break;
2504 }
2505
2506 case eeTRAP:
2507 {
2508 switch(guysbuf[new_id&0xFFF].misc2)
2509 {
2510 case 1:
2511 {
2512 enemy *e = new eTrap2(x,y,new_id,clk);
2513 guys.add(e);
2514 e->x = x;
2515 e->y = y;
2516 }
2517 break;
2518
2519 case 0:
2520 default:
2521 {
2522 enemy *e = new eTrap(x,y,new_id,clk);
2523 guys.add(e);
2524 e->x = x;
2525 e->y = y;
2526 }
2527 break;
2528 }
2529
2530 break;
2531 }
2532
2533 case eeDONGO:
2534 {
2535 switch(guysbuf[new_id&0xFFF].misc10)
2536 {
2537 case 1:
2538 {
2539 enemy *e = new eDodongo2(x,y,new_id,clk);
2540 guys.add(e);
2541 e->x = x;
2542 e->y = y;
2543 }
2544 break;
2545
2546 case 0:
2547 default:
2548 {
2549 enemy *e = new eDodongo(x,y,new_id,clk);
2550 guys.add(e);
2551 e->x = x;
2552 e->y = y;
2553 }
2554 break;
2555 }
2556
2557 break;
2558 }
2559
2560 case eeDIG:
2561 {
2562 switch(guysbuf[new_id&0xFFF].misc10)
2563 {
2564 case 1:
2565 {
2566 enemy *e = new eLilDig(x,y,new_id,clk);
2567 guys.add(e);
2568 e->x = x;
2569 e->y = y;
2570 }
2571 break;
2572
2573 case 0:
2574 default:
2575 {
2576 enemy *e = new eBigDig(x,y,new_id,clk);
2577 guys.add(e);
2578 e->x = x;
2579 e->y = y;
2580 }
2581 break;
2582 }
2583
2584 break;
2585 }
2586
2587 case eePATRA:
2588 {
2589 switch(guysbuf[new_id&0xFFF].misc10)
2590 {
2591 case 1:
2592 {
2593 if (get_qr(qr_HARDCODED_BS_PATRA))
2594 {
2595 enemy *e = new ePatraBS(x,y,new_id,clk);
2596 guys.add(e);
2597 e->x = x;
2598 e->y = y;
2599 break;
2600 }
2601 }
2602 [[fallthrough]];
2603 case 0:
2604 default:
2605 {
2606 enemy *e = new ePatra(x,y,new_id,clk);
2607 guys.add(e);
2608 e->x = x;
2609 e->y = y;
2610 }
2611 break;
2612 }
2613
2614 break;
2615 }
2616
2617 case eeGUY:
2618 {
2619 switch(guysbuf[new_id&0xFFF].misc10)
2620 {
2621 case 1:
2622 {
2623 enemy *e = new eTrigger(x,y,new_id,clk);
2624 guys.add(e);
2625 }
2626 break;
2627
2628 case 0:
2629 default:
2630 {
2631 enemy *e = new eNPC(x,y,new_id,clk);
2632 guys.add(e);
2633 }
2634 break;
2635 }
2636
2637 break;
2638 }
2639
2640 case eeSCRIPT01:
2641 case eeSCRIPT02:
2642 case eeSCRIPT03:
2643 case eeSCRIPT04:
2644 case eeSCRIPT05:
2645 case eeSCRIPT06:
2646 case eeSCRIPT07:
2647 case eeSCRIPT08:
2648 case eeSCRIPT09:
2649 case eeSCRIPT10:
2650 case eeSCRIPT11:
2651 case eeSCRIPT12:
2652 case eeSCRIPT13:
2653 case eeSCRIPT14:
2654 case eeSCRIPT15:
2655 case eeSCRIPT16:
2656 case eeSCRIPT17:
2657 case eeSCRIPT18:
2658 case eeSCRIPT19:
2659 case eeSCRIPT20:
2660 {
2661 enemy *e = new eScript(x,y,new_id,clk);
2662 guys.add(e);
2663 e->x = x;
2664 e->y = y;
2665 break;
2666 }
2667
2668
2669 case eeFFRIENDLY01:
2670 case eeFFRIENDLY02:
2671 case eeFFRIENDLY03:
2672 case eeFFRIENDLY04:
2673 case eeFFRIENDLY05:
2674 case eeFFRIENDLY06:
2675 case eeFFRIENDLY07:
2676 case eeFFRIENDLY08:
2677 case eeFFRIENDLY09:
2678 case eeFFRIENDLY10:
2679 {
2680 enemy *e = new eFriendly(x,y,new_id,clk);
2681 guys.add(e);
2682 e->x = x;
2683 e->y = y;
2684 break;
2685 }
2686
2687
2688 default: break;
2689 }
2690
2691 // add segments of segmented enemies
2692 int32_t c=0;
2693
2694 switch(guysbuf[new_id&0xFFF].family)
2695 {
2696 case eeMOLD:
2697 {
2698 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2699 new_id &= 0xFFF;
2700
2701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
2702 {
2703 //christ this is messy -DD
2704 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2705
2706 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2707 {
2708 al_trace("Moldorm segment %d could not be created!\n",i+1);
2709
2710 for(int32_t j=0; j<i+1; j++)
2711 guys.del(guys.Count()-1);
2712
2713 return 0;
2714 }
2715
2716 if(i>0)
2717 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2718
2719
2720 }
2721
2722 break;
2723 }
2724
2725 case eeLANM:
2726 {
2727 new_id &= 0xFFF;
2728 int32_t shft = guysbuf[new_id].misc2;
2729 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2730 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2731
2732 if(!guys.add(e))
2733 {
2734 al_trace("Lanmola segment 1 could not be created!\n");
2735 guys.del(guys.Count()-1);
2736 return 0;
2737 }
2738 e->x = x;
2739 e->y = y;
2740
2741
2742
2743 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
2744 {
2745 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2746 if(!guys.add(e2))
2747 {
2748 al_trace("Lanmola segment %d could not be created!\n",i+1);
2749
2750 for(int32_t j=0; j<i+1; j++)
2751 guys.del(guys.Count()-1);
2752
2753 return 0;
2754 }
2755 e2->x = x;
2756 e2->y = y;
2757
2758 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2759
2760 }
2761 }
2762 break;
2763
2764 case eeMANHAN:
2765 new_id &= 0xFFF;
2766
2767 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
2768 {
2769 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2770 {
2771 al_trace("Manhandla head %d could not be created!\n",i+1);
2772
2773 for(int32_t j=0; j<i+1; j++)
2774 {
2775 guys.del(guys.Count()-1);
2776 }
2777
2778 return 0;
2779 }
2780
2781
2782 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
2783 }
2784
2785 break;
2786
2787 case eeGLEEOK:
2788 {
2789 /*
2790 new_id &= 0xFFF;
2791 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2792 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2793 for(int32_t i=0; i<head_cnt; i++)
2794 {
2795 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2796 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2797 {
2798 al_trace("Gleeok head %d could not be created!\n",i+1);
2799
2800 for(int32_t j=0; j<i+1; j++)
2801 {
2802 guys.del(guys.Count()-1);
2803 }
2804
2805 break;
2806 }
2807
2808 c-=guysbuf[new_id].misc4;
2809 */
2810
2811 // }
2812 }
2813 break;
2814
2815
2816 case eePATRA:
2817 {
2818 new_id &= 0xFFF;
2819 int32_t outeyes = 0;
2820 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2821
2822 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
2823 {
2824 if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2825 {
2826 al_trace("Patra outer eye %d could not be created!\n",i+1);
2827
2828 for(int32_t j=0; j<i+1; j++)
2829 guys.del(guys.Count()-1);
2830
2831 return 0;
2832 }
2833 else
2834 outeyes++;
2835
2836
2837 }
2838
2839 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
2840 {
2841 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2842 {
2843 al_trace("Patra inner eye %d could not be created!\n",i+1);
2844
2845 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2846 guys.del(guys.Count()-1);
2847
2848 return 0;
2849 }
2850
2851
2852 }
2853 delete ptra;
2854 break;
2855 }
2856 }
2857
2858
2859
2860 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2861 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2862 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2863 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2864 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2865 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2866 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2867 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
2868 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2869 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2870 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2871 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2872 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2873 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2874
2875
2876 item_set = 0; //Do not make a drop.
2877
2878 switch(effect_type)
2879 {
2880 case -7:
2881 {
2882 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2883 Lwpns.add(w);
2884 break;
2885 }
2886 case -6:
2887 {
2888 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 case -5:
2893 {
2894 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2895 Lwpns.add(w);
2896 break;
2897 }
2898 case -4:
2899 {
2900 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2901 Lwpns.add(w);
2902 break;
2903 }
2904 case -3: explode(1); break;
2905 case -2: explode(2); break;
2906 case -1: explode(0); break;
2907 case 0: break;
2908
2909 default:
2910 {
2911 //Dummy weapon function
2912 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2913 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2914 Lwpns.add(w);
2915 break;
2916 }
2917 }
2918
2919
2920 yofs = -32768;
2921 switch(guysbuf[new_id&0xFFF].family)
2922 {
2923 case eeGLEEOK:
2924 {
2925 Z_scripterrlog("Replacing a gleeok.\n");
2926 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2927 hp = -999;
2928 tempenemy->hp = -999;
2929 break;
2930
2931 }
2932 default:
2933 hp = -1000; break;
2934 }
2935 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2936 return 1;
2937
2938 }
2939 case edSPLIT:
2940 {
2941 //int32_t ex = x; int32_t ey = y;
2942 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2943 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2944 /*
2945 if ( txsx > 1 )
2946 {
2947 ex += ( txsz-1 ) * 8; //from its middle
2948 }
2949 if ( tysx > 1 )
2950 {
2951 ey += ( tysz-1 ) * 8; //from its middle
2952 }
2953 */
2954 for ( int32_t q = 0; q < dmisc4; q++ )
2955 {
2956
2957 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
2958 addenemy(
2959 //ex,ey,
2960 x,y,
2961 dmisc3+0x1000,-15);
2962 //addenemy(ex,ey,dmisc3,0);
2963
2964 }
2965 item_set = 0; //Do not make a drop.
2966 hp = -1000;
2967 return -1;
2968
2969 }
2970 case edSUMMON:
2971 {
2972
2973
2974 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2975 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2976 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2977 for ( int32_t q = 0; q < summon_count; q++ )
2978 {
2979 int32_t x2=16*((zc_oldrand()%12)+2);
2980 int32_t y2=16*((zc_oldrand()%7)+2);
2981 addenemy(
2982 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2983 x2,y2,
2984 dmisc3+0x1000,-15);
2985 //addenemy(ex,ey,dmisc3,0);
2986
2987 }
2988 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2989 return -1;
2990
2991 }
2992
2993 case edEXPLODESMALL:
2994 {
2995 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2996 Ewpns.add(ew);
2997 item_set = 0; //Should we make a drop?
2998 hp = -1000;
2999 return -1;
3000 }
3001
3002
3003 case edEXPLODEHARMLESS:
3004 {
3005 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3006 Ewpns.add(ew);
3007 ew->hyofs = -32768;
3008 item_set = 0; //Should we make a drop?
3009 hp = -1000;
3010 return -1;
3011 }
3012
3013
3014 case edEXPLODELARGE:
3015 {
3016 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3017 Ewpns.add(ew);
3018
3019 hp = -1000;
3020 return -1;
3021 }
3022
3023
3024 case edTRIGGERSECRETS:
3025 {
3026 hidden_entrance(0, true, false, -4);
3027 return -1;
3028 }
3029
3030 case edSTUNORCHINK:
3031
3/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
3067 if (stunclk && get_qr(qr_NO_STUNLOCK))
3032 {
3033 sfx(WAV_CHINK,pan(int32_t(x)));
3034 return 1;
3035 }
3036
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1278 times.
1789 else if(*power <= 0)
3037 {
3038 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
3039 511 sfx(WAV_CHINK,pan(int32_t(x)));
3040 511 return 1;
3041 }
3042 [[fallthrough]];
3043
3044 case edSTUNORIGNORE:
3045
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
4578 if (stunclk && get_qr(qr_NO_STUNLOCK))
3046 {
3047 sfx(WAV_CHINK,pan(int32_t(x)));
3048 return 1;
3049 }
3050
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1887 times.
2691 else if(*power <= 0)
3051 804 return 0;
3052 [[fallthrough]];
3053
3054 case edSTUNONLY:
3055
7/10
✓ Branch 0 taken 2789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2733 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2760 times.
✓ Branch 9 taken 29 times.
2789 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3056 {
3057 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3058 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3059 29 return 1;
3060 }
3061
3/4
✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 625 times.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
2760 if (stunclk && get_qr(qr_NO_STUNLOCK))
3062 {
3063 sfx(WAV_CHINK,pan(int32_t(x)));
3064 return 1;
3065 }
3066 else
3067 {
3068 2760 stunclk=160;
3069 2760 sfx(WAV_EHIT,pan(int32_t(x)));
3070
3071 2760 return 1;
3072 }
3073
3074 case edCHINKL1:
3075 if(*power >= 1*game->get_hero_dmgmult()) break;
3076 [[fallthrough]];
3077 case edCHINKL2:
3078
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
3079 [[fallthrough]];
3080 case edCHINKL4:
3081
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
3082 [[fallthrough]];
3083 case edCHINKL6:
3084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
3085 [[fallthrough]];
3086 case edCHINKL8:
3087
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
3088 [[fallthrough]];
3089 case edCHINKL10:
3090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
3091 [[fallthrough]];
3092 case edCHINK:
3093 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
3094 219 sfx(WAV_CHINK,pan(int32_t(x)));
3095 219 return 1;
3096
3097 case edIGNOREL1:
3098 if(*power > 0) break;
3099 [[fallthrough]];
3100
3101 case edIGNORE:
3102 9312 return 0;
3103
3104 case ed1HKO:
3105 322 *power = hp;
3106 322 return -2;
3107
3108 case ed2x:
3109 {
3110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 *power = zc_max(1,*power*2);
3111 //int32_t pow = *power;
3112 //*power = vbound((pow*2),0,214747);
3113 71 return -1;
3114 }
3115 case ed3x:
3116 {
3117 *power = zc_max(1,*power*3);
3118 //int32_t pow = *power;
3119 //*power = vbound((pow*3),0,214747);
3120 return -1;
3121 }
3122
3123 case ed4x:
3124 {
3125 *power = zc_max(1,*power*4);
3126 //int32_t pow = *power;
3127 //*power = vbound((pow*4),0,214747);
3128 return -1;
3129 }
3130
3131
3132 case edHEAL:
3133 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3134 //int32_t pow = *power;
3135 //*power = vbound((pow*-1),0,214747);
3136 //break;
3137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
3138 79 return -1;
3139 }
3140 /*
3141 case edLEVELDAMAGE:
3142 {
3143 int32_t pow = *power;
3144 int32_t lvl = *level;
3145 *power = vbound((pow*lvl),0,214747);
3146 break;
3147 }
3148 case edLEVELREDUCTION:
3149 {
3150 int32_t pow = *power;
3151 int32_t lvl = *level;
3152 *power = vbound((pow/lvl),0,214747);
3153 break;
3154 }
3155 */
3156
3157 case edQUARTDAMAGE:
3158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 *power = zc_max(1,*power/2);
3159
3160 [[fallthrough]];
3161 case edHALFDAMAGE:
3162
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 230 times.
231 *power = zc_max(1,*power/2);
3163 231 break;
3164
3165 case edSWITCH:
3166 {
3167 if(Hero.switchhookclk) return 0; //Already switching!
3168 switch(family)
3169 {
3170 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3171 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3172 return 0;
3173 }
3174 hooked_combopos = -1;
3175 hooked_layerbits = 0;
3176 switching_object = this;
3177 switch_hooked = true;
3178 Hero.doSwitchHook(game->get_switchhookstyle());
3179 if(QMisc.miscsfx[sfxSWITCHED])
3180 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3181 return 1;
3182 }
3183
3184 case 0:
3185 {
3186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53312 times.
53312 if(edef == edefSwitchHook)
3187 return -1;
3188
6/6
✓ Branch 0 taken 13877 times.
✓ Branch 1 taken 39435 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 13848 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
53312 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3189 {
3190 13 sfx(WAV_CHINK,pan(int32_t(x)));
3191 13 return 1;
3192 }
3193
3194 }
3195 53299 }
3196
3197 53627 return -1;
3198 72097 }
3199
3200 72097 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3201 {
3202
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 int wuid = w?w->getUID():0;
3203
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3204
3205
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3206 Lwpns.add(w);
3207 72097 std::vector<int32_t> &ev = FFCore.eventData;
3208 72097 ev.clear();
3209 72097 ev.push_back(*power*10000);
3210 72097 ev.push_back(edef*10000);
3211 72097 ev.push_back(unblockable*10000);
3212 72097 ev.push_back(wpnId*10000);
3213 72097 ev.push_back(0);
3214 72097 ev.push_back(getUID());
3215 72097 ev.push_back(wuid);
3216
3217 72097 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3218 72097 *power = ev[0]/10000;
3219 72097 edef = ev[1]/10000;
3220 72097 unblockable = byte(ev[2]/10000);
3221 72097 wpnId = ev[3] / 10000;
3222 72097 bool nullify = ev[4]!=0;
3223 72097 ev.clear();
3224 72097 int ret = 0;
3225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(!nullify)
3226 {
3227 72097 ret = defendNew(wpnId, power, edef, unblockable);
3228
2/2
✓ Branch 0 taken 18999 times.
✓ Branch 1 taken 53098 times.
72097 if(ret == -1)
3229 {
3230 53098 ev.push_back(*power*10000);
3231 53098 ev.push_back(edef*10000);
3232 53098 ev.push_back(unblockable*10000);
3233 53098 ev.push_back(wpnId*10000);
3234 53098 ev.push_back(0);
3235 53098 ev.push_back(getUID());
3236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53098 times.
53098 ev.push_back(w?w->getUID():0);
3237
3238 53098 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3239 53098 *power = ev[0]/10000;
3240 53098 nullify = ev[4]!=0;
3241 53098 ev.clear();
3242 53098 }
3243 72097 }
3244
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3245 Lwpns.remove(w);
3246
3247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 return nullify ? 0 : ret;
3248 }
3249
3250 53720 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3251 {
3252
2/2
✓ Branch 0 taken 53490 times.
✓ Branch 1 taken 230 times.
53720 if(!realweap) realweap = w;
3253 53720 int32_t wid = getWeaponID(w);
3254
3255 53720 int32_t edef = resolveEnemyDefence(w);
3256
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 52464 times.
53720 if(QHeader.zelda_version > 0x250)
3257 1256 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3258
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51471 times.
✗ Branch 2 not taken.
52464 switch(wid)
3259 {
3260 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3261 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3262 993 return defend(wpnId, power, edefSCRIPT);
3263
3264 case wWhistle:
3265 return -1;
3266
3267 default:
3268 51471 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3269 }
3270 53720 }
3271
3272
3273 // Check defenses without actually acting on them.
3274 11966 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3275 {
3276
4/10
✓ Branch 0 taken 9574 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11966 switch(defense[edef])
3277 {
3278 case edSTUNONLY:
3279 8 return false;
3280 case edSTUNORCHINK:
3281 case edCHINK:
3282 9574 return unblockable&WPNUNB_BLOCK;
3283 case edSTUNORIGNORE:
3284 case edIGNORE:
3285 2059 return unblockable&WPNUNB_IGNR;
3286
3287 case edIGNOREL1:
3288 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3289 case edCHINKL1:
3290 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3291
3292 case edCHINKL2:
3293 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3294
3295 case edCHINKL4:
3296 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3297
3298 case edCHINKL6:
3299 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3300
3301 case edCHINKL8:
3302 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3303 }
3304
3305 325 return true;
3306 11966 }
3307
3308 // Do we do damage?
3309 // 0: takehit returns 0
3310 // 1: takehit returns 1
3311 // -1: do damage
3312 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3313 {
3314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3315 {
3316 switch(defense[edef])
3317 {
3318 case edIGNORE:
3319 return 0;
3320 case edIGNOREL1:
3321 case edSTUNORIGNORE:
3322 if(*power <= 0)
3323 return 0;
3324 }
3325
3326 sfx(WAV_CHINK,pan(int32_t(x)));
3327 return 1;
3328 }
3329
3330
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3331 {
3332 case edSTUNORCHINK:
3333 if(*power <= 0)
3334 {
3335 sfx(WAV_CHINK,pan(int32_t(x)));
3336 return 1;
3337 }
3338
3339 [[fallthrough]];
3340 case edSTUNORIGNORE:
3341 if(*power <= 0)
3342 return 0;
3343
3344 [[fallthrough]];
3345 case edSTUNONLY:
3346 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3347 return 1;
3348
3349 stunclk=160;
3350 sfx(WAV_EHIT,pan(int32_t(x)));
3351 return 1;
3352
3353 case edFREEZE:
3354 frozenclock=-1;
3355 //sfx(WAV_FREEZE,pan(int32_t(x)));
3356 return 1;
3357
3358 case edCHINKL1:
3359 if(*power >= 1*game->get_hero_dmgmult()) break;
3360 [[fallthrough]];
3361 case edCHINKL2:
3362 if(*power >= 2*game->get_hero_dmgmult()) break;
3363 [[fallthrough]];
3364 case edCHINKL4:
3365 if(*power >= 4*game->get_hero_dmgmult()) break;
3366 [[fallthrough]];
3367 case edCHINKL6:
3368 if(*power >= 6*game->get_hero_dmgmult()) break;
3369 [[fallthrough]];
3370 case edCHINKL8:
3371 if(*power >= 8*game->get_hero_dmgmult()) break;
3372 [[fallthrough]];
3373 case edCHINKL10:
3374 if(*power >= 10*game->get_hero_dmgmult()) break;
3375 [[fallthrough]];
3376 case edCHINK:
3377 sfx(WAV_CHINK,pan(int32_t(x)));
3378 return 1;
3379 case edTRIGGERSECRETS:
3380 hidden_entrance(0, true, false, -4);
3381 break;
3382
3383 case edIGNOREL1:
3384 if(*power > 0) break;
3385 [[fallthrough]];
3386 case edIGNORE:
3387 800 return 0;
3388
3389 case ed1HKO:
3390 *power = hp;
3391 return -2;
3392
3393 case ed2x:
3394 {
3395 *power = zc_max(1,*power*2);
3396 //int32_t pow = *power;
3397 //*power = vbound((pow*2),0,214747);
3398 return -1;
3399 }
3400 case ed3x:
3401 {
3402 *power = zc_max(1,*power*3);
3403 //int32_t pow = *power;
3404 //*power = vbound((pow*3),0,214747);
3405 return -1;
3406 }
3407
3408 case ed4x:
3409 {
3410 *power = zc_max(1,*power*4);
3411 //int32_t pow = *power;
3412 //*power = vbound((pow*4),0,214747);
3413 return -1;
3414 }
3415
3416
3417 case edHEAL:
3418 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3419 //int32_t pow = *power;
3420 //*power = vbound((pow*-1),0,214747);
3421 //break;
3422 *power = zc_min(0,*power*-1);
3423 return -1;
3424 }
3425 /*
3426 case edLEVELDAMAGE:
3427 {
3428 int32_t pow = *power;
3429 int32_t lvl = *level;
3430 *power = vbound((pow*lvl),0,214747);
3431 break;
3432 }
3433 case edLEVELREDUCTION:
3434 {
3435 int32_t pow = *power;
3436 int32_t lvl = *level;
3437 *power = vbound((pow/lvl),0,214747);
3438 break;
3439 }
3440 */
3441
3442
3443 case edQUARTDAMAGE:
3444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3445
3446 [[fallthrough]];
3447 case edHALFDAMAGE:
3448
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 *power = zc_max(1,*power/2);
3449 7 break;
3450 }
3451
3452 193 return -1;
3453 993 }
3454
3455 // Defend against a particular item class.
3456 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3457 {
3458 int32_t def=-1;
3459
3460 switch(wpnId)
3461 {
3462 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3463 case wBrang:
3464 def = defend(wpnId, power, edefBRANG);
3465 break;
3466
3467 case wHookshot:
3468 def = defend(wpnId, power, edefHOOKSHOT);
3469 break;
3470
3471 // Anyway...
3472 case wBomb:
3473 def = defend(wpnId, power, edefBOMB);
3474 break;
3475
3476 case wSBomb:
3477 def = defend(wpnId, power, edefSBOMB);
3478 break;
3479
3480 case wArrow:
3481 def = defend(wpnId, power, edefARROW);
3482 break;
3483
3484 case wFire:
3485 def = defend(wpnId, power, edefFIRE);
3486 break;
3487
3488 case wWand:
3489 def = defend(wpnId, power, edefWAND);
3490 break;
3491
3492 case wMagic:
3493 def = defend(wpnId, power, edefMAGIC);
3494 break;
3495
3496 case wHammer:
3497 def = defend(wpnId, power, edefHAMMER);
3498 break;
3499
3500 case wSword:
3501 def = defend(wpnId, power, edefSWORD);
3502 break;
3503
3504 case wBeam:
3505 def = defend(wpnId, power, edefBEAM);
3506 break;
3507
3508 case wRefBeam:
3509 def = defend(wpnId, power, edefREFBEAM);
3510 break;
3511
3512 case wRefMagic:
3513 def = defend(wpnId, power, edefREFMAGIC);
3514 break;
3515
3516 case wRefFireball:
3517 def = defend(wpnId, power, edefREFBALL);
3518 break;
3519
3520 case wRefRock:
3521 def = defend(wpnId, power, edefREFROCK);
3522 break;
3523
3524 case wStomp:
3525 def = defend(wpnId, power, edefSTOMP);
3526 break;
3527
3528 case wCByrna:
3529 def = defend(wpnId, power, edefBYRNA);
3530 break;
3531
3532 case wScript1:
3533 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3534 else def = defend(wpnId, power, edefSCRIPT);
3535 break;
3536
3537 case wScript2:
3538 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3539 else def = defend(wpnId, power, edefSCRIPT);
3540 break;
3541
3542 case wScript3:
3543 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3544 else def = defend(wpnId, power, edefSCRIPT);
3545 break;
3546
3547 case wScript4:
3548 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3549 else def = defend(wpnId, power, edefSCRIPT);
3550 break;
3551
3552 case wScript5:
3553 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3554 else def = defend(wpnId, power, edefSCRIPT);
3555 break;
3556
3557 case wScript6:
3558 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3559 else def = defend(wpnId, power, edefSCRIPT);
3560 break;
3561
3562 case wScript7:
3563 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3564 else def = defend(wpnId, power, edefSCRIPT);
3565 break;
3566
3567 case wScript8:
3568 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3569 else def = defend(wpnId, power, edefSCRIPT);
3570 break;
3571
3572 case wScript9:
3573 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3574 else def = defend(wpnId, power, edefSCRIPT);
3575 break;
3576
3577 case wScript10:
3578 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3579 else def = defend(wpnId, power, edefSCRIPT);
3580 break;
3581
3582 case wWhistle:
3583 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3584 else break;
3585 break;
3586
3587
3588 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3589 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3590 //of the ten if the quest version is lower than N.
3591 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3592 //such as bool UseSeparatedScriptDefences. hah.
3593 default:
3594 //if(wpnId>=wScript1 && wpnId<=wScript10)
3595 // {
3596 // def = defend(wpnId, power, edefSCRIPT);
3597 // }
3598 // }
3599
3600 break;
3601 }
3602
3603 return def;
3604 }
3605
3606 // take damage or ignore it
3607 // -1: damage (if any) dealt
3608 // 1: blocked
3609 // 0: weapon passes through unhindered
3610 159739 int32_t enemy::takehit(weapon *w, weapon* realweap)
3611 {
3612
2/4
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159739 times.
159739 if(fallclk||drownclk) return 0;
3613
2/2
✓ Branch 0 taken 34416 times.
✓ Branch 1 taken 125323 times.
159739 if(!realweap) realweap = w;
3614 159739 int32_t wpnId = w->id;
3615 159739 int32_t power = w->power;
3616 159739 int32_t wpnx = w->x;
3617 159739 int32_t wpny = w->y;
3618 159739 int32_t enemyHitWeapon = w->parentitem;
3619 int32_t wpnDir;
3620 159739 int32_t parent_item = w->parentitem;
3621
3622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159739 times.
159739 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3623 {
3624 wpnId = w->useweapon;
3625 }
3626
3627 // If it's a boomerang that just bounced, use the opposite direction;
3628 // otherwise, it might bypass a shield. This probably won't handle
3629 // every case correctly, but it's better than having shields simply
3630 // not work against boomerangs.
3631
8/8
✓ Branch 0 taken 18979 times.
✓ Branch 1 taken 140760 times.
✓ Branch 2 taken 11895 times.
✓ Branch 3 taken 7084 times.
✓ Branch 4 taken 11291 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 2653 times.
✓ Branch 7 taken 8638 times.
159739 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3632 8638 wpnDir = oppositeDir[w->dir];
3633 else
3634 151101 wpnDir = w->dir;
3635
3636
5/8
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2479 times.
✓ Branch 7 taken 160110 times.
159739 if(dying || clk<0 || hclk>0 || superman)
3637 2479 return 0;
3638
3639 //Prevent boomerang from writing to hitby[] for more than one frame.
3640 //This also prevents stunlock.
3641 //if ( stunclk > 0 ) return 0;
3642 //this needs a rule for boomerangs that cannot stunlock!
3643 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3644 //sigh.
3645
3646 160110 int32_t ret = -1;
3647
3648 // This obscure quest rule...
3649
5/6
✓ Branch 0 taken 77360 times.
✓ Branch 1 taken 82750 times.
✓ Branch 2 taken 77192 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 77192 times.
160110 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3650 {
3651 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3652 168 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3653 168 wpnDir=zc_oldrand()&3;
3654
3655
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
168 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3656 {
3657 59 wpnDir=down;
3658 59 }
3659
4/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 56 times.
109 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3660 {
3661 56 wpnDir=right;
3662 56 }
3663
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 14 times.
53 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3664 {
3665 14 wpnDir=up;
3666 14 }
3667 else
3668 {
3669 39 wpnDir=left;
3670 }
3671 168 }
3672
3673 160110 int32_t xdir = dir;
3674 160110 shieldCanBlock=false;
3675
3676 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
3677
4/4
✓ Branch 0 taken 158266 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 157860 times.
160905 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3678
10/10
✓ Branch 0 taken 13418 times.
✓ Branch 1 taken 13012 times.
✓ Branch 2 taken 18111 times.
✓ Branch 3 taken 152761 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 152703 times.
✓ Branch 6 taken 984 times.
✓ Branch 7 taken 151719 times.
✓ Branch 8 taken 795 times.
✓ Branch 9 taken 150924 times.
158266 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
3679 )
3680 // The hammer should already be dealt with by subclasses (Walker etc.)
3681 {
3682
9/9
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3758 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1317 times.
✓ Branch 8 taken 484 times.
33366 switch(wpnId)
3683 {
3684 // Weapons which shields protect against
3685 case wSword:
3686 case wWand:
3687
1/2
✓ Branch 0 taken 3758 times.
✗ Branch 1 not taken.
3758 if(Hero.getCharging()>0)
3688 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3689
3690 [[fallthrough]];
3691 case wHookshot:
3692 case wHSHandle:
3693 case wBrang:
3694 4021 shieldCanBlock=true;
3695 4273 break;
3696
3697 case wBeam:
3698 case wRefBeam:
3699 // Mirror shielded enemies!
3700 #if 0
3701 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3702 {
3703 if(wpnId>wEnemyWeapons)
3704 return 0;
3705
3706 sfx(WAV_CHINK,pan(int32_t(x)));
3707 return 1;
3708 }
3709
3710 #endif
3711
3712 [[fallthrough]];
3713 case wRefRock:
3714 case wRefFireball:
3715 case wMagic:
3716 #if 0
3717 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3718 {
3719 sfx(WAV_CHINK,pan(int32_t(x)));
3720 return 3;
3721 }
3722
3723 #endif
3724
3725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(wpnId>wEnemyWeapons)
3726 return 0;
3727
3728 [[fallthrough]];
3729 default:
3730 1597 shieldCanBlock=true;
3731 1597 break;
3732
3733 // Bombs
3734 case wSBomb:
3735 case wBomb:
3736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3737 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3738 {
3739 sfx(WAV_CHINK,pan(int32_t(x)));
3740 return 0;
3741 }
3742 else break;
3743
3744 // Weapons which ignore shields
3745 case wWhistle:
3746 case wHammer:
3747 1 break;
3748
3749 // Weapons which shouldn't be removed by shields
3750 case wLitBomb:
3751 case wLitSBomb:
3752 case wWind:
3753 case wPhantom:
3754 case wSSparkle:
3755 case wBait:
3756 423 return 0;
3757
3758 case wFire:
3759 ;
3760 484 }
3761 6103 }
3762
3763
7/8
✓ Branch 0 taken 72714 times.
✓ Branch 1 taken 53047 times.
✓ Branch 2 taken 211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11966 times.
✓ Branch 5 taken 18964 times.
✓ Branch 6 taken 406 times.
✓ Branch 7 taken 1563 times.
158871 switch(wpnId)
3764 {
3765 case wWhistle: //No longer completely ignore whistle weapons! -Z
3766 {
3767
3768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3769 {
3770 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
3771 211 return 0; break;
3772 }
3773 else
3774 {
3775 w->power = power = itemsbuf[parent_item].misc5;
3776
3777 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3778
3779 if(def <= 0)
3780 {
3781 if ( def == -2 ) hp -= hp;
3782 else hp -= power;
3783 return def;
3784 }
3785 break;
3786 }
3787 break;
3788 }
3789
3790 case wPhantom:
3791 return 0;
3792
3793 case wLitBomb:
3794 case wLitSBomb:
3795 case wBait:
3796 case wWind:
3797 case wSSparkle:
3798 72714 return 0;
3799
3800 case wFSparkle:
3801
3802 // Only take sparkle damage if the sparkle's parent item is not
3803 // defended against.
3804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11966 times.
11966 if(enemyHitWeapon > -1)
3805 {
3806 11966 int32_t p = 0;
3807 11966 int32_t f = itemsbuf[enemyHitWeapon].family;
3808
3809
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11966 times.
11966 switch(f)
3810 {
3811 case itype_arrow:
3812 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3813
3814 break;
3815
3816 case itype_cbyrna:
3817 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3818
3819 break;
3820
3821 case itype_brang:
3822
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 11641 times.
11966 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3823
3824 325 break;
3825
3826 default:
3827 return 0;
3828 }
3829 325 }
3830
3831 325 wpnId = wSword;
3832 325 power = game->get_hero_dmgmult()>>1;
3833 325 goto fsparkle;
3834 break;
3835
3836 case wBrang:
3837 {
3838 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3839 18964 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3840 //preventing stunlock might be best, here. -Z
3841
2/2
✓ Branch 0 taken 4250 times.
✓ Branch 1 taken 14714 times.
18964 if(def >= 0) return def;
3842
3843 // Not hurt by 0-damage weapons
3844
2/2
✓ Branch 0 taken 2271 times.
✓ Branch 1 taken 12443 times.
14714 if(!(flags & guy_bhit))
3845 {
3846 12443 stunclk=160;
3847
3848
3/4
✓ Branch 0 taken 12443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 11243 times.
12443 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3849 {
3850
1/2
✓ Branch 0 taken 1200 times.
✗ Branch 1 not taken.
1200 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3851 1200 goto hitclock;
3852 }
3853
3854 11243 break;
3855 }
3856
3857
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1887 times.
2271 if(!power)
3858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1887 times.
1887 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3859 else
3860 384 hp-=power;
3861
3862 2271 goto hitclock;
3863 }
3864
3865 case wHookshot:
3866 {
3867 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3868 406 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3869
3870
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 221 times.
406 if(def >= 0) return def;
3871
3872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3873
3/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 6 times.
221 if(swgrab || !(flags & guy_bhit))
3874 {
3875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(!swgrab)
3876 215 stunclk=160;
3877
3878
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3879 {
3880 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3881 goto hitclock;
3882 }
3883
3884 215 break;
3885 }
3886
3887
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3888 else
3889 hp-=power;
3890
3891 6 goto hitclock;
3892 }
3893 break;
3894
3895 case wHSHandle:
3896 {
3897
3/4
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1484 times.
1563 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
3898 79 return 0;
3899
3900
3/4
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
1484 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
391 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3902
3903 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3904
6/8
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 370 times.
1801 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3905
6/6
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 651 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 334 times.
452 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
3906 334 return 0;
3907
3908 2182 power = game->get_hero_dmgmult();
3909 2507 }
3910
3911 fsparkle:
3912
3913 [[fallthrough]];
3914 default:
3915 // Work out the defenses!
3916 {
3917 53490 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3918
3919
2/2
✓ Branch 0 taken 14920 times.
✓ Branch 1 taken 38570 times.
53490 if(def >= 0)
3920 14920 return def;
3921
2/2
✓ Branch 0 taken 38280 times.
✓ Branch 1 taken 290 times.
38570 else if(def == -2)
3922 {
3923 290 ret = 0;
3924 290 }
3925 }
3926
3927
2/2
✓ Branch 0 taken 38568 times.
✓ Branch 1 taken 2 times.
77140 if(!power)
3928 {
3929
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3930 2 hp-=1;
3931 else
3932 {
3933 // Don't make a long chain of 'stun' hits
3934 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3935 return 1;
3936
3937
3938 if(!switch_hooked)
3939 stunclk=160;
3940 break;
3941 }
3942 2 }
3943 38568 else hp-=power;
3944
3945 hitclock:
3946 42051 hclk=33;
3947
3948 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3949
2/2
✓ Branch 0 taken 19451 times.
✓ Branch 1 taken 22600 times.
42051 if((dir&2)==(w->dir&2))
3950 {
3951 22600 sclk=(w->dir<<8)+16;
3952 22600 }
3953 42051 }
3954
3955
5/6
✓ Branch 0 taken 38795 times.
✓ Branch 1 taken 14714 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 46788 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6721 times.
53509 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3956 {
3957 6721 fading=fade_blue_poof;
3958 6721 }
3959
3960
6/6
✓ Branch 0 taken 52505 times.
✓ Branch 1 taken 1004 times.
✓ Branch 2 taken 34805 times.
✓ Branch 3 taken 17700 times.
✓ Branch 4 taken 1927 times.
✓ Branch 5 taken 32878 times.
53509 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3961 {
3962
1/2
✓ Branch 0 taken 2931 times.
✗ Branch 1 not taken.
2931 if( hitsfx > 0 ) //user-set hit sound.
3963 {
3964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2931 times.
2931 if (!dying) //don't play the hit sound on death! -Z
3965 2931 sfx(hitsfx, pan(int32_t(x)));
3966 2931 }
3967 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3968 2931 }
3969 else //2.50.2 or earlier
3970 {
3971 50578 sfx(WAV_EHIT, pan(int32_t(x)));
3972 50578 sfx(hitsfx, pan(int32_t(x)));
3973 }
3974
2/2
✓ Branch 0 taken 53499 times.
✓ Branch 1 taken 10 times.
53509 if(family==eeGUY)
3975 10 sfx(WAV_EDEAD, pan(int32_t(x)));
3976
3977 // Penetrating weapons
3978
4/4
✓ Branch 0 taken 52712 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 47718 times.
✓ Branch 3 taken 5791 times.
53509 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3979 {
3980 5791 int32_t item=enemyHitWeapon;
3981
3982
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 5149 times.
5791 if(wpnId==wArrow)
3983 {
3984 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3985
5/6
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
642 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
3986 70 return 0;
3987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3988 //if(item<0)
3989 else
3990 572 item=current_item_id(itype_arrow);
3991 572 }
3992
3993 else
3994 {
3995
3996 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3997
3/6
✓ Branch 0 taken 5131 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5149 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
3998 return 0;
3999
4000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
5149 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
4001 else
4002 //if(item<0)
4003 5149 item=current_item_id(itype_sword);
4004 }
4005 5721 }
4006
4007 53439 return ret;
4008 160745 }
4009
4010 29336178 bool enemy::dont_draw()
4011 {
4012
6/6
✓ Branch 0 taken 29225703 times.
✓ Branch 1 taken 110475 times.
✓ Branch 2 taken 29154796 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 34059 times.
✓ Branch 5 taken 29191644 times.
29336178 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4013 144534 return true;
4014
4015
2/2
✓ Branch 0 taken 286146 times.
✓ Branch 1 taken 28905498 times.
29191644 if(flags&guy_invisible)
4016 286146 return true;
4017
4018
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 28905066 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
28905498 if(flags&lens_only && !lensclk)
4019 return true;
4020
4021
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 28859547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28905498 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
4022 !((flags&lens_only) && (get_qr(qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
4023 return true;
4024
4025 28905498 return false;
4026 29336178 }
4027
4028 #define DRAW_NORMAL 2
4029 #define DRAW_CLOAKED 1
4030 #define DRAW_INVIS 0
4031 // base drawing function to be used by all derived classes instead of
4032 // sprite::draw()
4033 24868949 void enemy::draw(BITMAP *dest)
4034 {
4035 24868949 didScriptThisFrame = false; //Since there's no better place to put it
4036
6/6
✓ Branch 0 taken 24511254 times.
✓ Branch 1 taken 357695 times.
✓ Branch 2 taken 24428604 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 153876 times.
✓ Branch 5 taken 24357378 times.
24868949 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4037 511571 return;
4038
2/2
✓ Branch 0 taken 1573842 times.
✓ Branch 1 taken 22783536 times.
24357378 if(flags&guy_invisible)
4039 1573842 return;
4040
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22757278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22783536 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
4041 return;
4042
4043 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4044 // be cloaked if they have "invisible displays as cloaked" checked.
4045
4046 22783536 byte canSee = DRAW_NORMAL;
4047 //Enemy specific stuff
4048
1/2
✓ Branch 0 taken 22783536 times.
✗ Branch 1 not taken.
22783536 if ( editorflags & ENEMY_FLAG1 )
4049 {
4050 canSee = DRAW_INVIS;
4051 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4052 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4053 {
4054 if (game->item[dmisc13])
4055 {
4056 canSee = DRAW_NORMAL;
4057 }
4058 //else if ( lensclk && getlensid.flags SHOWINVIS )
4059 //{
4060 //
4061 //}
4062 //else
4063 //{
4064 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4065 // //otherwisem invisible
4066 //}
4067 }
4068 }
4069 //Room specific
4070
2/2
✓ Branch 0 taken 22591512 times.
✓ Branch 1 taken 192024 times.
22783536 if (tmpscr->flags3&fINVISROOM)
4071 {
4072
4/6
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33839 times.
✓ Branch 3 taken 158185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33839 times.
225863 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33839 times.
33839 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4074 192024 }
4075 //Lens check
4076
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22757278 times.
22783536 if (lensclk)
4077 {
4078
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
4079 {
4080 if (canSee == DRAW_NORMAL)
4081 {
4082 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
4083 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
4084 }
4085 }
4086
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
4087 {
4088
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4089 432 }
4090 26258 }
4091 else
4092 {
4093
2/2
✓ Branch 0 taken 22683862 times.
✓ Branch 1 taken 73416 times.
22757278 if(flags&lens_only)
4094 73416 canSee = DRAW_INVIS;
4095 }
4096
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 22710120 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
22783536 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4097
3/4
✓ Branch 0 taken 22676281 times.
✓ Branch 1 taken 107255 times.
✓ Branch 2 taken 22676281 times.
✗ Branch 3 not taken.
22783536 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4098
4099
2/2
✓ Branch 0 taken 22710120 times.
✓ Branch 1 taken 73416 times.
22783536 if (canSee == DRAW_INVIS)
4100 73416 return;
4101
4102
3/4
✓ Branch 0 taken 22709978 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22709978 times.
22710120 if(fallclk||drownclk)
4103 {
4104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
4105 {
4106 sprite::drawcloaked(dest);
4107 }
4108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
4109 {
4110 142 sprite::draw(dest);
4111 142 }
4112 142 return;
4113 }
4114 22709978 int32_t cshold=cs;
4115
4116
2/2
✓ Branch 0 taken 531444 times.
✓ Branch 1 taken 22178534 times.
22709978 if(dying)
4117 {
4118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if(clk2>=19)
4119 {
4120 if(!(clk2&2))
4121 {
4122 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4123 if (canSee == DRAW_CLOAKED)
4124 {
4125 sprite::drawcloaked(dest);
4126 }
4127 else if (canSee == DRAW_NORMAL)
4128 {
4129 sprite::draw(dest);
4130 }
4131 }
4132 return;
4133 }
4134
4135 531444 flip = 0;
4136 531444 tile = wpnsbuf[spr_death].tile;
4137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if ( do_animation )
4138 {
4139 531444 int32_t offs = 0;
4140
2/2
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4141 {
4142
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
4143 {
4144 239 spr_death_anim_clk=0;
4145 239 clk2=1;
4146
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
4147 235 death_sfx();
4148 239 }
4149
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
4150 {
4151 4456 ++clk2;
4152
1/2
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm *= zc_max(1,txsz);
4154 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4155
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 4382 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4156
4/6
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4217 times.
✓ Branch 5 taken 239 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4157 {
4158 239 spr_death_anim_clk=-1;
4159 239 clk2=1;
4160 239 }
4161 4456 }
4162 4807 tile += spr_death_anim_frm;
4163 4807 }
4164
2/2
✓ Branch 0 taken 79136 times.
✓ Branch 1 taken 447501 times.
526637 else if(BSZ)
4165 {
4166
2/2
✓ Branch 0 taken 62225 times.
✓ Branch 1 taken 16911 times.
79136 offs = zc_min((15-clk2)/3,4);
4167 79136 }
4168
4/4
✓ Branch 0 taken 298376 times.
✓ Branch 1 taken 149125 times.
✓ Branch 2 taken 149349 times.
✓ Branch 3 taken 149027 times.
447501 else if(clk2>6 && clk2<=12)
4169 {
4170 149349 offs = 1;
4171 149349 }
4172
4173
2/2
✓ Branch 0 taken 314434 times.
✓ Branch 1 taken 217010 times.
531444 if(offs)
4174 {
4175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217010 times.
217010 offs *= zc_max(1,txsz);
4176 217010 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4177
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4178 217010 }
4179 531444 tile += offs;
4180 531444 }
4181
4182
6/6
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 447501 times.
✓ Branch 3 taken 79136 times.
✓ Branch 4 taken 129054 times.
✓ Branch 5 taken 318447 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4183 212997 cs = wpnsbuf[spr_death].csets&15;
4184 else
4185 318447 cs = (((clk2+5)>>1)&3)+6;
4186 531444 }
4187
3/4
✓ Branch 0 taken 662995 times.
✓ Branch 1 taken 21515539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662995 times.
22178534 else if(hclk>0 && getCanFlicker())
4188 {
4189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662995 times.
662995 if(family==eeGANON)
4190 cs=(((hclk-1)>>1)&3)+6;
4191
4/4
✓ Branch 0 taken 613464 times.
✓ Branch 1 taken 49531 times.
✓ Branch 2 taken 174016 times.
✓ Branch 3 taken 439448 times.
662995 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4192 439448 cs=(((hclk-1)>>1)&3)+6;
4193 662995 }
4194 //draw every other frame for flickering enemies
4195
8/10
✓ Branch 0 taken 11349319 times.
✓ Branch 1 taken 11360659 times.
✓ Branch 2 taken 11349319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 567307 times.
✓ Branch 5 taken 10782012 times.
✓ Branch 6 taken 137002 times.
✓ Branch 7 taken 430305 times.
✓ Branch 8 taken 137002 times.
✗ Branch 9 not taken.
22709978 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER) && getCanFlicker()))
4196 {
4197
2/2
✓ Branch 0 taken 33668 times.
✓ Branch 1 taken 22539308 times.
22572976 if (canSee == DRAW_CLOAKED)
4198 {
4199 33668 sprite::drawcloaked(dest);
4200 33668 }
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22539308 times.
22539308 else if (canSee == DRAW_NORMAL)
4202 {
4203
1/2
✓ Branch 0 taken 22539308 times.
✗ Branch 1 not taken.
22539308 if ( frozenclock < 0 )
4204 {
4205 if ( frozentile > 0 ) tile = frozentile;
4206 loadpalset(csBOSS,frozencset);
4207 }
4208 22539308 sprite::draw(dest);
4209 22539308 }
4210 22572976 }
4211 22709978 cs=cshold;
4212 24868949 }
4213
4214 //old zc bosses
4215 23264120 void enemy::drawzcboss(BITMAP *dest)
4216 {
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23264120 times.
23264120 if(dont_draw())
4218 return;
4219
4220 23264120 int32_t cshold=cs;
4221
4222
2/2
✓ Branch 0 taken 492438 times.
✓ Branch 1 taken 22771682 times.
23264120 if(dying)
4223 {
4224
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 489846 times.
492438 if(clk2>=19)
4225 {
4226
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
4227 1296 sprite::drawzcboss(dest);
4228
4229 2592 return;
4230 }
4231
4232 489846 flip = 0;
4233 489846 tile = wpnsbuf[spr_death].tile;
4234
4235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 489846 times.
489846 if ( do_animation )
4236 {
4237
2/2
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4238 {
4239
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
4240 {
4241 2 spr_death_anim_clk=0;
4242 2 clk2=1;
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
4244 2 death_sfx();
4245 2 }
4246
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
4247 {
4248 2 ++clk2;
4249
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm *= zc_max(1,txsz);
4251 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4253
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4254 {
4255 spr_death_anim_clk=-1;
4256 clk2=1;
4257 }
4258 2 }
4259 2186 tile += spr_death_anim_frm;
4260 2186 }
4261
2/2
✓ Branch 0 taken 79248 times.
✓ Branch 1 taken 408412 times.
487660 else if(BSZ)
4262
2/2
✓ Branch 0 taken 62313 times.
✓ Branch 1 taken 16935 times.
79248 tile += zc_min((15-clk2)/3,4);
4263
4/4
✓ Branch 0 taken 272202 times.
✓ Branch 1 taken 136210 times.
✓ Branch 2 taken 136236 times.
✓ Branch 3 taken 135966 times.
408412 else if(clk2>6 && clk2<=12)
4264 136236 ++tile;
4265 489846 }
4266
4267
6/6
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 408412 times.
✓ Branch 3 taken 79248 times.
✓ Branch 4 taken 125904 times.
✓ Branch 5 taken 282508 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4268 207338 cs = wpnsbuf[spr_death].csets&15;
4269 else
4270 282508 cs = (((clk2+5)>>1)&3)+6;
4271 489846 }
4272
2/2
✓ Branch 0 taken 22105172 times.
✓ Branch 1 taken 666510 times.
22771682 else if(hclk>0)
4273 {
4274
2/2
✓ Branch 0 taken 2916 times.
✓ Branch 1 taken 663594 times.
666510 if(family==eeGANON)
4275 2916 cs=(((hclk-1)>>1)&3)+6;
4276
4/4
✓ Branch 0 taken 619253 times.
✓ Branch 1 taken 44341 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 508788 times.
663594 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4277 508788 cs=(((hclk-1)>>1)&3)+6;
4278 666510 }
4279
4280
3/4
✓ Branch 0 taken 167600 times.
✓ Branch 1 taken 23093928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2948 times.
23264476 if((tmpscr->flags3&fINVISROOM) &&
4281
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 164652 times.
167600 !(current_item(itype_amulet)) &&
4282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2948 times.
2948 !(get_qr(qr_LENSSEESENEMIES) &&
4283 2948 lensclk) && family!=eeGANON)
4284 {
4285 2948 sprite::drawcloaked(dest);
4286 2948 }
4287 else
4288 {
4289
6/6
✓ Branch 0 taken 23236088 times.
✓ Branch 1 taken 22492 times.
✓ Branch 2 taken 1090454 times.
✓ Branch 3 taken 22145634 times.
✓ Branch 4 taken 930949 times.
✓ Branch 5 taken 159505 times.
23258580 if(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER))
4290 {
4291
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
4292 143685 sprite::drawzcboss(dest);
4293 159505 }
4294 else
4295 23099075 sprite::drawzcboss(dest);
4296 }
4297
4298 23261528 cs=cshold;
4299 23264120 }
4300
4301
4302 // similar to the overblock function--can do up to a 32x32 sprite
4303 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4304 136827 void enemy::drawblock(BITMAP *dest,int32_t mask)
4305 {
4306 136827 int32_t thold=tile;
4307 136827 int32_t t1=tile;
4308 136827 int32_t t2=tile+20;
4309 136827 int32_t t3=tile+1;
4310 136827 int32_t t4=tile+21;
4311
4312
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 136827 times.
136827 switch(mask)
4313 {
4314 case 1:
4315 enemy::drawzcboss(dest);
4316 break;
4317
4318 case 3:
4319 if(flip&2)
4320 zc_swap(t1,t2);
4321
4322 tile=t1;
4323 enemy::drawzcboss(dest);
4324 tile=t2;
4325 yofs+=16;
4326 enemy::drawzcboss(dest);
4327 yofs-=16;
4328 break;
4329
4330 case 5:
4331 t2=tile+1;
4332
4333 if(flip&1)
4334 zc_swap(t1,t2);
4335
4336 tile=t1;
4337 enemy::drawzcboss(dest);
4338 tile=t2;
4339 xofs+=16;
4340 enemy::drawzcboss(dest);
4341 xofs-=16;
4342 break;
4343
4344 case 15:
4345
2/2
✓ Branch 0 taken 130714 times.
✓ Branch 1 taken 6113 times.
136827 if(flip&1)
4346 {
4347 6113 zc_swap(t1,t3);
4348 6113 zc_swap(t2,t4);
4349 6113 }
4350
4351
1/2
✓ Branch 0 taken 136827 times.
✗ Branch 1 not taken.
136827 if(flip&2)
4352 {
4353 zc_swap(t1,t2);
4354 zc_swap(t3,t4);
4355 }
4356
4357 136827 tile=t1;
4358 136827 enemy::drawzcboss(dest);
4359 136827 tile=t2;
4360 136827 yofs+=16;
4361 136827 enemy::drawzcboss(dest);
4362 136827 yofs-=16;
4363 136827 tile=t3;
4364 136827 xofs+=16;
4365 136827 enemy::drawzcboss(dest);
4366 136827 tile=t4;
4367 136827 yofs+=16;
4368 136827 enemy::drawzcboss(dest);
4369 136827 xofs-=16;
4370 136827 yofs-=16;
4371 136827 break;
4372 }
4373
4374 136827 tile=thold;
4375 136827 }
4376
4377 5844593 void enemy::drawshadow(BITMAP *dest, bool translucent)
4378 {
4379
4/4
✓ Branch 0 taken 5413913 times.
✓ Branch 1 taken 430680 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 5007824 times.
5844593 if(dont_draw() || isSideViewGravity())
4380 {
4381 836769 return;
4382 }
4383
4384
2/2
✓ Branch 0 taken 80005 times.
✓ Branch 1 taken 4927819 times.
5007824 if(dying)
4385 {
4386 80005 return;
4387 }
4388
4389
4/4
✓ Branch 0 taken 2116 times.
✓ Branch 1 taken 4925703 times.
✓ Branch 2 taken 147668 times.
✓ Branch 3 taken 4780151 times.
4927819 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4390 4927819 (darkroom))
4391 {
4392 147668 return;
4393 }
4394 else
4395 {
4396
4/4
✓ Branch 0 taken 4562620 times.
✓ Branch 1 taken 217531 times.
✓ Branch 2 taken 4550013 times.
✓ Branch 3 taken 12607 times.
4780151 if(enemycanfall(id, false) && shadowtile == 0)
4397 12607 shadowtile = wpnsbuf[spr_shadow].tile;
4398
4399
5/6
✓ Branch 0 taken 4208101 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 4208101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3990570 times.
✓ Branch 5 taken 217531 times.
4780151 if(z>0 || fakez>0 || !enemycanfall(id, false))
4400 {
4401
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 789465 times.
789581 if(!shadow_overpit(this))
4402 789465 sprite::drawshadow(dest,translucent);
4403 789581 }
4404 }
4405 5844593 }
4406
4407 88213 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4408 {
4409 88213 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4410
4411
1/2
✓ Branch 0 taken 88213 times.
✗ Branch 1 not taken.
88213 if(sub!=NULL)
4412 {
4413 88213 xofs-=mx;
4414 88213 yofs-=my;
4415 88213 enemy::draw(sub);
4416 88213 xofs+=mx;
4417 88213 yofs+=my;
4418 88213 destroy_bitmap(sub);
4419 88213 }
4420 else
4421 enemy::draw(dest);
4422 88213 }
4423
4424 // override hit detection to check for invicibility, stunned, etc
4425 66869774 bool enemy::hit()
4426 {
4427
4/4
✓ Branch 0 taken 66045021 times.
✓ Branch 1 taken 824753 times.
✓ Branch 2 taken 64957400 times.
✓ Branch 3 taken 1087621 times.
66869774 if(dying || hclk>0) return false;
4428 64957400 return sprite::hit();
4429 66869774 }
4430 52704 bool enemy::hit(sprite *s)
4431 {
4432
3/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52264 times.
✓ Branch 3 taken 440 times.
52704 if(!hit() || !s->hit()) return false;
4433 52264 return sprite::hit(s);
4434 52704 }
4435
4436 27515818 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4437 {
4438
2/2
✓ Branch 0 taken 2179256 times.
✓ Branch 1 taken 25336562 times.
27515818 if(!hit()) return false;
4439 25336562 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4440 27515818 }
4441 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4442 {
4443 if(!hit()) return false;
4444 return sprite::hit(tx,ty,txsz2,tysz2);
4445 }
4446
4447 7434715 bool enemy::hit(weapon *w)
4448 {
4449
2/2
✓ Branch 0 taken 851646 times.
✓ Branch 1 taken 6583069 times.
7434715 if(!hit()) return false;
4450
4451
2/2
✓ Branch 0 taken 6581733 times.
✓ Branch 1 taken 1336 times.
6583069 if (replay_version_check(0, 14))
4452 {
4453
4/6
✓ Branch 0 taken 6361773 times.
✓ Branch 1 taken 219960 times.
✓ Branch 2 taken 6361773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6361773 times.
✗ Branch 5 not taken.
6581733 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk)
4454 219960 return false;
4455 6361773 return sprite::hit(w);
4456 }
4457 1336 return w->hit(this);
4458 7434715 }
4459
4460 6076892 bool enemy::can_pitfall(bool checkspawning)
4461 {
4462
4/4
✓ Branch 0 taken 6068985 times.
✓ Branch 1 taken 7907 times.
✓ Branch 2 taken 6067149 times.
✓ Branch 3 taken 9743 times.
6076892 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4463
2/2
✓ Branch 0 taken 6059681 times.
✓ Branch 1 taken 7468 times.
6067149 switch(guysbuf[id&0xFFF].family)
4464 {
4465 case eeAQUA:
4466 case eeDIG:
4467 case eeDONGO:
4468 case eeFAIRY:
4469 case eeGANON:
4470 case eeGHOMA:
4471 case eeGLEEOK:
4472 case eeGUY:
4473 case eeLANM:
4474 case eeMANHAN:
4475 case eeMOLD:
4476 case eeNONE:
4477 case eePATRA:
4478 case eeZORA:
4479 7468 return false; //Disallowed types
4480 default:
4481 6059681 return true;
4482 }
4483 6076892 }
4484 //Handle death
4485 21147339 void enemy::try_death(bool force_kill)
4486 {
4487
8/8
✓ Branch 0 taken 21106412 times.
✓ Branch 1 taken 40927 times.
✓ Branch 2 taken 21106410 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24644 times.
✓ Branch 5 taken 21081766 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 24643 times.
21147339 if(!dying && (force_kill || (hp<=0 && !immortal)))
4488 {
4489 24645 std::vector<int32_t> &ev = FFCore.eventData;
4490 24645 ev.clear();
4491 24645 ev.push_back(10000);
4492 24645 ev.push_back(getUID());
4493
4494 24645 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4495 24645 bool isSaved = !ev[0];
4496 24645 ev.clear();
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24645 times.
24645 if(isSaved) return;
4498
4499
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24621 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 22 times.
24645 if(itemguy && (hasitem&2)!=0)
4500 {
4501
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 22 times.
47 for(int32_t i=0; i<items.Count(); i++)
4502 {
4503
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 22 times.
25 if(((item*)items.spr(i))->pickup&ipENEMY)
4504 {
4505
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4506 {
4507 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4508 {
4509 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4510 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4511 }
4512 else
4513 {
4514 if(extend >= 3)
4515 {
4516 items.spr(i)->x = x+(txsz-1)*8;
4517 items.spr(i)->y = y-2+(tysz-1)*8;
4518 }
4519 else
4520 {
4521 items.spr(i)->x = x;
4522 items.spr(i)->y = y - 2;
4523 }
4524 }
4525 items.spr(i)->z = z;
4526 items.spr(i)->fakez = fakez;
4527 }
4528 else
4529 {
4530 22 items.spr(i)->x = x;
4531 22 items.spr(i)->y = y - 2;
4532 }
4533 22 }
4534 25 }
4535 22 }
4536
4537 24645 dying=true;
4538
4539
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24623 times.
24645 if(fading==fade_flash_die)
4540 22 clk2=19+18*4;
4541 else
4542 {
4543 24623 clk2 = BSZ ? 15 : 19;
4544
4545
2/2
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 17949 times.
24623 if(fading!=fade_blue_poof)
4546 17949 fading=0;
4547 }
4548
4549
2/2
✓ Branch 0 taken 24621 times.
✓ Branch 1 taken 24 times.
24645 if(itemguy)
4550 {
4551 24 hasitem&=~2;
4552 24 item_set=0;
4553 24 }
4554
4555
6/6
✓ Branch 0 taken 23961 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 19569 times.
✓ Branch 3 taken 4392 times.
✓ Branch 4 taken 644 times.
✓ Branch 5 taken 18925 times.
24645 if(currscr<128 && count_enemy && !script_spawned)
4556 18925 game->guys[(currmap<<7)+currscr]-=1;
4557 24645 }
4558 21147339 }
4559
4560 // --==**==--
4561
4562 // Movement routines that can be used by derived classes as needed
4563
4564 // --==**==--
4565
4566 324311 void enemy::fix_coords(bool bound)
4567 {
4568
1/2
✓ Branch 0 taken 324311 times.
✗ Branch 1 not taken.
324311 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4569
1/2
✓ Branch 0 taken 324311 times.
✗ Branch 1 not taken.
324311 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
4570
4571
4572
2/2
✓ Branch 0 taken 41509 times.
✓ Branch 1 taken 282802 times.
324311 if(bound)
4573 {
4574
1/2
✓ Branch 0 taken 282802 times.
✗ Branch 1 not taken.
282802 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4575 {
4576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282802 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282802 x=vbound(x, 0, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256-((txsz-1)*16)) : 240));
4577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282802 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282802 y=vbound(y, 0,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176-((txsz-1)*16)) : 160));
4578 282802 }
4579 else
4580 {
4581 x=vbound(x, 0,240);
4582 y=vbound(y, 0,160);
4583 }
4584 282802 }
4585
4586
6/10
✓ Branch 0 taken 323297 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 324311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 324311 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 324311 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 324311 times.
324311 if(!OUTOFBOUNDS)
4587 {
4588 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4589
4590 if(isSideViewGravity())
4591 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4592 else
4593 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4594 */
4595 324311 do_fix(x, 16, true);
4596
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 323297 times.
324311 if(isSideViewGravity())
4597 1014 do_fix(y,8,true);
4598 323297 else do_fix(y,16,true);
4599 324311 }
4600 324311 }
4601 6036 bool enemy::cannotpenetrate()
4602 {
4603
4/4
✓ Branch 0 taken 5919 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5900 times.
6036 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4604 }
4605
4606 394 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4607 {
4608 bool ok;
4609 394 int32_t dx = 0, dy = 0;
4610 394 int32_t sv = 8;
4611
4612 //Why is this here??? Why is it needed???
4613 394 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4614
4615
8/9
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 56 times.
✗ Branch 8 not taken.
394 switch(ndir)
4616 {
4617 case 8:
4618 case up:
4619
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
44 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 44 dy = dy1-s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 special = (special==spw_clipbottomright)?spw_none:special;
4624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4625 44 break;
4626
4627 case 12:
4628 case down:
4629
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
40 if(canfall(id) && isSideViewGravity())
4630 return false;
4631
4632 40 dy = dy2+s;
4633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4634 40 break;
4635
4636 case 14:
4637 case left:
4638 34 dx = dx1-s;
4639 34 sv = ((isSideViewGravity())?7:8);
4640
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4641
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
34 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4642 34 break;
4643
4644 case 10:
4645 case right:
4646 55 dx = dx2+s;
4647 55 sv = ((isSideViewGravity())?7:8);
4648
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 50 times.
55 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4649 55 break;
4650
4651 case 9:
4652 case r_up:
4653 66 dx = dx2+s;
4654 66 dy = dy1-s;
4655
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 1 times.
131 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4657 66 break;
4658
4659 case 11:
4660 case r_down:
4661 56 dx = dx2+s;
4662 56 dx = dy2+s;
4663
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4665 56 break;
4666
4667 case 13:
4668 case l_down:
4669 43 dx = dx1-s;
4670 43 dy = dy2+s;
4671
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
84 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4673 43 break;
4674
4675 case 15:
4676 case l_up:
4677 56 dx = dx1-s;
4678 56 dy = dy1-s;
4679
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4681 56 break;
4682
4683 default:
4684 db=99;
4685 return true;
4686 }
4687
4688 394 return ok;
4689 394 }
4690
4691
4692
4693
4694 // returns true if next step is ok, false if there is something there
4695 3806293 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4696 {
4697 3806293 bool ok = false; //initialise the var, son't just declare it
4698 3806293 int32_t dx = 0, dy = 0;
4699 3806293 int32_t sv = 8;
4700 3806293 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4701 //Why is this here??? Why is it needed???
4702 3806293 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806293 times.
3806293 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806293 times.
3806293 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806293 times.
3806293 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806293 times.
3806293 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4707 3806293 bool offgrid = OFFGRID_ENEMY;
4708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806293 times.
3806293 if(!offgrid)
4709 {
4710 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4711
1/2
✓ Branch 0 taken 3806293 times.
✗ Branch 1 not taken.
3806293 if(usehei<16)usehei=16;
4712
1/2
✓ Branch 0 taken 3806293 times.
✗ Branch 1 not taken.
3806293 if(usewid<16)usewid=16;
4713 3806293 }
4714
9/9
✓ Branch 0 taken 708831 times.
✓ Branch 1 taken 565122 times.
✓ Branch 2 taken 629146 times.
✓ Branch 3 taken 634146 times.
✓ Branch 4 taken 290259 times.
✓ Branch 5 taken 347714 times.
✓ Branch 6 taken 321027 times.
✓ Branch 7 taken 306379 times.
✓ Branch 8 taken 3669 times.
3806293 switch(ndir) //need to check every 8 pixels between two points
4715 {
4716 case 8:
4717 case up:
4718 {
4719
4/4
✓ Branch 0 taken 96567 times.
✓ Branch 1 taken 612264 times.
✓ Branch 2 taken 95977 times.
✓ Branch 3 taken 590 times.
708831 if(enemycanfall(id) && isSideViewGravity())
4720 590 return false;
4721
4722 708241 dy = dy1-s;
4723
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708238 times.
708241 special = (special==spw_clipbottomright)?spw_none:special;
4724 708241 tries = usewid/(offgrid ? 8 : 16);
4725 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4726
2/2
✓ Branch 0 taken 607804 times.
✓ Branch 1 taken 708241 times.
1316045 for ( ; tries > 0; --tries )
4727 {
4728
2/2
✓ Branch 0 taken 98395 times.
✓ Branch 1 taken 609846 times.
708241 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4729 708241 try_x += (offgrid ? 8 : 16);
4730
2/2
✓ Branch 0 taken 607804 times.
✓ Branch 1 taken 100437 times.
708241 if (!ok) break;
4731 607804 }
4732
2/2
✓ Branch 0 taken 607804 times.
✓ Branch 1 taken 100437 times.
708241 if(!ok) break;
4733
1/2
✓ Branch 0 taken 607804 times.
✗ Branch 1 not taken.
607804 if((usewid%16)>0) //Uneven width
4734 {
4735 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4736 }
4737 607804 break;
4738 }
4739 case 12:
4740 case down:
4741 {
4742
4/4
✓ Branch 0 taken 107022 times.
✓ Branch 1 taken 458100 times.
✓ Branch 2 taken 106334 times.
✓ Branch 3 taken 688 times.
565122 if(enemycanfall(id) && isSideViewGravity())
4743 688 return false;
4744
4745 564434 dy = dy2+s;
4746 564434 tries = usewid/(offgrid ? 8 : 16);
4747 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4748
2/2
✓ Branch 0 taken 460644 times.
✓ Branch 1 taken 564434 times.
1025078 for ( ; tries > 0; --tries )
4749 {
4750
3/4
✓ Branch 0 taken 103361 times.
✓ Branch 1 taken 461073 times.
✓ Branch 2 taken 461073 times.
✗ Branch 3 not taken.
564434 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4751 564434 try_x += (offgrid ? 8 : 16);
4752
2/2
✓ Branch 0 taken 460644 times.
✓ Branch 1 taken 103790 times.
564434 if (!ok) break;
4753 460644 }
4754
2/2
✓ Branch 0 taken 460644 times.
✓ Branch 1 taken 103790 times.
564434 if(!ok) break;
4755
1/2
✓ Branch 0 taken 460644 times.
✗ Branch 1 not taken.
460644 if((usewid%16)>0) //Uneven width
4756 {
4757 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4758 }
4759 460644 break;
4760 }
4761 case 14:
4762 case left:
4763 {
4764 629146 dx = dx1-s;
4765 629146 sv = ((isSideViewGravity())?7:0);
4766
4/4
✓ Branch 0 taken 629140 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1272 times.
✓ Branch 3 taken 627868 times.
629146 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4767 629146 tries = usehei/(offgrid ? 8 : 16);
4768 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4769
2/2
✓ Branch 0 taken 532648 times.
✓ Branch 1 taken 629146 times.
1161794 for ( ; tries > 0; --tries )
4770 {
4771
2/2
✓ Branch 0 taken 95665 times.
✓ Branch 1 taken 533481 times.
629146 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4772 629146 try_y += (offgrid ? 8 : 16);
4773
2/2
✓ Branch 0 taken 532648 times.
✓ Branch 1 taken 96498 times.
629146 if (!ok) break;
4774 532648 }
4775
2/2
✓ Branch 0 taken 532648 times.
✓ Branch 1 taken 96498 times.
629146 if(!ok) break;
4776
1/2
✓ Branch 0 taken 532648 times.
✗ Branch 1 not taken.
532648 if((usehei%16)>0) //Uneven height
4777 {
4778 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4779 }
4780 532648 break;
4781 }
4782 case 10:
4783 case right:
4784 {
4785 634146 dx = dx2+s;
4786 634146 sv = ((isSideViewGravity())?7:0);
4787 634146 tries = usehei/(offgrid ? 8 : 16);
4788 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4789
2/2
✓ Branch 0 taken 540182 times.
✓ Branch 1 taken 634146 times.
1174328 for ( ; tries > 0; --tries )
4790 {
4791
3/4
✓ Branch 0 taken 93176 times.
✓ Branch 1 taken 540970 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 540970 times.
634146 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4792 634146 try_y += (offgrid ? 8 : 16);
4793
2/2
✓ Branch 0 taken 540182 times.
✓ Branch 1 taken 93964 times.
634146 if (!ok) break;
4794 540182 }
4795
2/2
✓ Branch 0 taken 540182 times.
✓ Branch 1 taken 93964 times.
634146 if(!ok) break;
4796
1/2
✓ Branch 0 taken 540182 times.
✗ Branch 1 not taken.
540182 if((usehei%16)>0) //Uneven height
4797 {
4798 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4799 }
4800 540182 break;
4801 }
4802 case 9:
4803 case r_up:
4804 {
4805 290259 dx = dx2+s;
4806 290259 dy = dy1-s;
4807 290259 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4808 290259 sv = ((isSideViewGravity())?7:0);
4809
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_x > 0; --tries_x )
4810 {
4811 290259 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4812 290259 try_y = 0;
4813
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_y > 0; --tries_y )
4814 {
4815
4/4
✓ Branch 0 taken 286282 times.
✓ Branch 1 taken 3977 times.
✓ Branch 2 taken 283302 times.
✓ Branch 3 taken 2980 times.
573561 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4816
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 281502 times.
283302 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4817 290259 try_y += (offgrid ? 8 : 16);
4818
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4819 280834 }
4820
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280834 times.
280834 if((usehei%16)>0) //Uneven height
4822 {
4823 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4824 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4825 }
4826 280834 try_x += (offgrid ? 8 : 16);
4827 280834 }
4828
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if(!ok) break;
4829
1/2
✓ Branch 0 taken 280834 times.
✗ Branch 1 not taken.
280834 if((usewid%16)>0) //Uneven width
4830 {
4831 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4832 try_y = 0;
4833 for ( ; tries_y > 0; --tries_y )
4834 {
4835 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4836 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4837 try_y += (offgrid ? 8 : 16);
4838 if (!ok) break;
4839 }
4840 if (!ok) break;
4841 if((usehei%16)>0) //Uneven height
4842 {
4843 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4844 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4845 }
4846 }
4847 280834 break;
4848 }
4849 case 11:
4850 case r_down:
4851 {
4852 347714 dx = dx2+s;
4853 347714 dx = dy2+s;
4854 347714 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4855 //sv = ((isSideViewGravity())?7:0);
4856
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_x > 0; --tries_x )
4857 {
4858 347714 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4859 347714 try_y = 0;
4860
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_y > 0; --tries_y )
4861 {
4862
4/4
✓ Branch 0 taken 347575 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 340363 times.
✓ Branch 3 taken 7212 times.
688077 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4863
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 340321 times.
340363 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4864 347714 try_y += (offgrid ? 8 : 16);
4865
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4866 339823 }
4867
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339823 times.
339823 if((usehei%16)>0) //Uneven height
4869 {
4870 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4871 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4872 }
4873 339823 try_x += (offgrid ? 8 : 16);
4874 339823 }
4875
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if(!ok) break;
4876
1/2
✓ Branch 0 taken 339823 times.
✗ Branch 1 not taken.
339823 if((usewid%16)>0) //Uneven width
4877 {
4878 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4879 try_y = 0;
4880 for ( ; tries_y > 0; --tries_y )
4881 {
4882 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4883 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4884 try_y += (offgrid ? 8 : 16);
4885 if (!ok) break;
4886 }
4887 if (!ok) break;
4888 if((usehei%16)>0) //Uneven height
4889 {
4890 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4891 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4892 }
4893 }
4894 339823 break;
4895 }
4896 case 13:
4897 case l_down:
4898 {
4899 321027 dx = dx1-s;
4900 321027 dy = dy2+s;
4901 321027 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4902 //sv = ((isSideViewGravity())?7:0);
4903
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_x > 0; --tries_x )
4904 {
4905 321027 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4906 321027 try_y = 0;
4907
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_y > 0; --tries_y )
4908 {
4909
4/4
✓ Branch 0 taken 315731 times.
✓ Branch 1 taken 5296 times.
✓ Branch 2 taken 313353 times.
✓ Branch 3 taken 2378 times.
634380 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4910
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 313025 times.
313353 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4911 321027 try_y += (offgrid ? 8 : 16);
4912
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4913 312908 }
4914
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312908 times.
312908 if((usehei%16)>0) //Uneven height
4916 {
4917 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4918 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4919 }
4920 312908 try_x += (offgrid ? 8 : 16);
4921 312908 }
4922
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if(!ok) break;
4923
1/2
✓ Branch 0 taken 312908 times.
✗ Branch 1 not taken.
312908 if((usewid%16)>0) //Uneven width
4924 {
4925 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4926 try_y = 0;
4927 for ( ; tries_y > 0; --tries_y )
4928 {
4929 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4930 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4931 try_y += (offgrid ? 8 : 16);
4932 if (!ok) break;
4933 }
4934 if (!ok) break;
4935 if((usehei%16)>0) //Uneven height
4936 {
4937 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4938 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4939 }
4940 }
4941 312908 break;
4942 }
4943 case 15:
4944 case l_up:
4945 {
4946 306379 dx = dx1-s;
4947 306379 dy = dy1-s;
4948 306379 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4949 306379 sv = ((isSideViewGravity())?7:0);
4950
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_x > 0; --tries_x )
4951 {
4952 306379 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4953 306379 try_y = 0;
4954
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_y > 0; --tries_y )
4955 {
4956
4/4
✓ Branch 0 taken 302185 times.
✓ Branch 1 taken 4194 times.
✓ Branch 2 taken 299965 times.
✓ Branch 3 taken 2220 times.
606344 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4957
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 298047 times.
299965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4958 306379 try_y += (offgrid ? 8 : 16);
4959
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4960 297417 }
4961
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297417 times.
297417 if((usehei%16)>0) //Uneven height
4963 {
4964 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4966 }
4967 297417 try_x += (offgrid ? 8 : 16);
4968 297417 }
4969
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if(!ok) break;
4970
1/2
✓ Branch 0 taken 297417 times.
✗ Branch 1 not taken.
297417 if((usewid%16)>0) //Uneven width
4971 {
4972 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4973 try_y = 0;
4974 for ( ; tries_y > 0; --tries_y )
4975 {
4976 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4977 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4978 try_y += (offgrid ? 8 : 16);
4979 if (!ok) break;
4980 }
4981 if (!ok) break;
4982 if((usehei%16)>0) //Uneven height
4983 {
4984 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4985 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4986 }
4987 }
4988 297417 break;
4989 }
4990 default:
4991 3669 db=99;
4992 3669 return true;
4993 }
4994 //Z_eventlog("\n");
4995 3801346 return ok;
4996 3806293 }
4997
4998
4999 2471515 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
5000 {
5001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471515 times.
2471515 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471515 times.
2471515 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5003
1/2
✓ Branch 0 taken 2471515 times.
✗ Branch 1 not taken.
2471515 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5004
1/2
✓ Branch 0 taken 2471515 times.
✗ Branch 1 not taken.
2471515 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5005 2471515 --usewid;
5006 2471515 --usehei;
5007 2471515 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5008 }
5009
5010 663783 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5011 {
5012 663783 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5013
5014
4/4
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 658995 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 1192 times.
663783 if(special==spw_clipright&&ndir==right)
5015 {
5016 1192 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5017 1192 }
5018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663783 times.
663783 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663783 times.
663783 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5020
1/2
✓ Branch 0 taken 663783 times.
✗ Branch 1 not taken.
663783 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5021
1/2
✓ Branch 0 taken 663783 times.
✗ Branch 1 not taken.
663783 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5022 663783 --usewid;
5023 663783 --usehei;
5024
2/2
✓ Branch 0 taken 357484 times.
✓ Branch 1 taken 306299 times.
663783 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5025 }
5026
5027 65432 bool enemy::canmove(int32_t ndir, bool kb)
5028 {
5029 65432 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5030 }
5031
5032 // 8-directional
5033 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5034 {
5035 394 int32_t ndir=0;
5036
5037 // can move straight, check if it wants to turn
5038
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 9 times.
394 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5039 {
5040
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5041 {
5042 int32_t w = Lwpns.idFirst(wBait);
5043
5044 if(w>=0)
5045 {
5046 int32_t bx = Lwpns.spr(w)->x;
5047 int32_t by = Lwpns.spr(w)->y;
5048
5049 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5050
5051 if(abs(int32_t(y)-by)>14)
5052 {
5053 if(ndir>0) // Already left or right
5054 {
5055 // Making the diagonal directions
5056 ndir += (by<y) ? 2 : 4;
5057 }
5058 else
5059 {
5060 ndir = (by<y) ? up : down;
5061 }
5062 }
5063
5064 if(canmove(ndir,special,false))
5065 {
5066 dir=ndir;
5067 return;
5068 }
5069 }
5070 }
5071
5072 // Homing added.
5073
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(newhoming && (zc_oldrand()&255)<newhoming)
5074 {
5075 ndir = lined_up(8,true);
5076
5077 if(ndir>=0 && canmove(ndir,special,false))
5078 {
5079 dir=ndir;
5080 }
5081
5082 return;
5083 }
5084
5085 385 int32_t r=zc_oldrand();
5086
5087
2/4
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
385 if(newrate>0 && !(r%newrate))
5088 {
5089 385 ndir = ((dir+((r&64)?-1:1))&7)+8;
5090 385 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5091
5092
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
385 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5093 371 dir=ndir;
5094
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5095 11 dir=ndir2;
5096
5097
3/4
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 371 times.
✗ Branch 3 not taken.
385 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5098 // due to numerous lost fractional components. -L
5099 {
5100 x.doFloor();
5101 y.doFloor();
5102 }
5103 385 }
5104
5105 385 return;
5106 }
5107
5108 // can't move straight, must turn
5109 9 int32_t i=0;
5110
5111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for(; i<32; i++) // Try random dir
5112 {
5113 16 ndir=(zc_oldrand()&7)+8;
5114
5115
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
16 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5116 9 break;
5117 7 }
5118
5119
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(i==32)
5120 {
5121 for(ndir=8; ndir<16; ndir++)
5122 {
5123 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5124 goto ok;
5125 }
5126
5127 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5128 }
5129
5130 ok:
5131 9 dir=ndir;
5132 9 x.doFloor();
5133 9 y.doFloor();
5134 394 }
5135
5136 311413 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5137 {
5138 311413 int32_t ndir=0;
5139
5140 // can move straight, check if it wants to turn
5141
2/2
✓ Branch 0 taken 293564 times.
✓ Branch 1 taken 17849 times.
311413 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5142 {
5143
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 293357 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
293564 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5144 {
5145 101 int32_t i = Lwpns.idFirst(wBait);
5146
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5147 {
5148 weapon *w = (weapon*)Lwpns.spr(i);
5149 if (get_qr(qr_FIND_CLOSEST_BAIT))
5150 {
5151 int32_t currentrange;
5152 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5153 else currentrange = -1;
5154 int curid = i;
5155 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5156 for(; i<Lwpns.Count(); ++i)
5157 {
5158 weapon *lw = (weapon*)Lwpns.spr(i);
5159 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5160 {
5161 currentrange = distance(x, y, lw->x, lw->y);
5162 curid = i;
5163 }
5164 }
5165 i = curid;
5166 if (currentrange == -1) i = -1;
5167 }
5168 else
5169 {
5170 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5171 }
5172 if(i>=0)
5173 {
5174 int32_t bx = Lwpns.spr(i)->x;
5175 int32_t by = Lwpns.spr(i)->y;
5176
5177 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5178
5179 if(abs(int32_t(y)-by)>14)
5180 {
5181 if(ndir>0) // Already left or right
5182 {
5183 // Making the diagonal directions
5184 ndir += (by<y) ? 2 : 4;
5185 }
5186 else
5187 {
5188 ndir = (by<y) ? up : down;
5189 }
5190 }
5191 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5192 if(canmove(ndir,special,false))
5193 {
5194 dir=ndir;
5195 return;
5196 }
5197 }
5198 }
5199 101 }
5200
5201 // Homing added.
5202
4/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 292999 times.
✓ Branch 2 taken 409 times.
✓ Branch 3 taken 156 times.
293564 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5203 {
5204 156 ndir = lined_up(8,true);
5205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5206
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 87 times.
156 if(ndir>=0 && canmove(ndir,special,false))
5207 {
5208 87 dir=ndir;
5209 87 }
5210
5211 156 return;
5212 }
5213
5214 293408 int32_t r=zc_oldrand();
5215
5216
4/4
✓ Branch 0 taken 184141 times.
✓ Branch 1 taken 109267 times.
✓ Branch 2 taken 99386 times.
✓ Branch 3 taken 84755 times.
293408 if(newrate>0 && !(r%newrate))
5217 {
5218 84755 ndir = ((dir+((r&64)?-1:1))&7)+8;
5219 84755 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5220
5221
2/2
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
84755 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5222 81873 dir=ndir;
5223
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 2702 times.
2882 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5224 2702 dir=ndir2;
5225
5226
4/4
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
✓ Branch 2 taken 77990 times.
✓ Branch 3 taken 3883 times.
84755 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5227 // due to numerous lost fractional components. -L
5228 {
5229 3883 x.doFloor();
5230 3883 y.doFloor();
5231 3883 }
5232 84755 }
5233
5234 293408 return;
5235 }
5236
5237 // can't move straight, must turn
5238 17849 int32_t i=0;
5239
5240
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 33819 times.
33847 for(; i<32; i++) // Try random dir
5241 {
5242 33819 ndir=(zc_oldrand()&7)+8;
5243
5244
2/2
✓ Branch 0 taken 15998 times.
✓ Branch 1 taken 17821 times.
33819 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5245 17821 break;
5246 15998 }
5247
5248
2/2
✓ Branch 0 taken 17821 times.
✓ Branch 1 taken 28 times.
17866 if(i==32)
5249 {
5250
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 17 times.
172 for(ndir=8; ndir<16; ndir++)
5251 {
5252
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 11 times.
155 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5253 11 goto ok;
5254 144 }
5255
5256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5257 17 }
5258
5259 ok:
5260 17849 dir=ndir;
5261 17849 x.doFloor();
5262 17849 y.doFloor();
5263 311413 }
5264
5265 307935 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5266 {
5267 307935 newdir_8(newrate,newhoming,special,0,-8,15,15);
5268 307935 }
5269
5270 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5271 {
5272 394 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5273 394 }
5274
5275 // makes the enemy slide backwards when hit
5276 // sclk: first byte is clk, second byte is dir
5277 // makes the enemy slide backwards when hit
5278 // sclk: first byte is clk, second byte is dir
5279 9374767 int32_t enemy::slide()
5280 {
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9374767 times.
9374767 if(script_knockback_clk!=0) //scripted knockback
5282 {
5283 sclk = 0;
5284 return 1; //scripted knockback ran
5285 }
5286
5/6
✓ Branch 0 taken 55775 times.
✓ Branch 1 taken 9318992 times.
✓ Branch 2 taken 5384 times.
✓ Branch 3 taken 50391 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5384 times.
9374767 if(sclk==0 || (hp<=0 && !immortal))
5287 9324376 return 0;
5288
5289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50391 times.
50391 if(knockbackflags & FLAG_NOSLIDE)
5290 {
5291 sclk = 0;
5292 if(!OFFGRID_ENEMY)
5293 {
5294 //Fix to grid
5295 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5296 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5297 do_fix(x, 16, true);
5298 do_fix(y, 16, true);
5299 }
5300 return 0;
5301 }
5302
8/10
✓ Branch 0 taken 5089 times.
✓ Branch 1 taken 45302 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 5064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3796 times.
✓ Branch 7 taken 1268 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
50391 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5303 {
5304 1268 sclk=0;
5305 1268 return 0;
5306 }
5307
5308 49123 --sclk;
5309
5310
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 6052 times.
✓ Branch 2 taken 6364 times.
✓ Branch 3 taken 16287 times.
✓ Branch 4 taken 18763 times.
49123 switch(sclk>>8)
5311 {
5312 case up:
5313 {
5314
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6046 times.
6052 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5315 {
5316 6 sclk=0;
5317 6 return 0;
5318 }
5319
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5372 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 110 times.
6046 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5320
5321 5936 break;
5322 }
5323 case down:
5324 {
5325
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6362 times.
6364 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5326 {
5327 2 sclk=0;
5328 2 return 0;
5329 }
5330
4/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 5593 times.
✓ Branch 2 taken 668 times.
✓ Branch 3 taken 101 times.
6362 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5331
5332 6261 break;
5333 }
5334 case left:
5335 {
5336
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14874 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 16274 times.
16287 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5337 {
5338 13 sclk=0;
5339 13 return 0;
5340 }
5341
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14861 times.
✓ Branch 2 taken 1295 times.
✓ Branch 3 taken 118 times.
16274 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5342
5343 16156 break;
5344 }
5345 case right:
5346 {
5347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763 times.
18763 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5348 {
5349 sclk=0;
5350 return 0;
5351 }
5352
4/4
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 16402 times.
✓ Branch 2 taken 2195 times.
✓ Branch 3 taken 166 times.
18763 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5353 18597 break;
5354 }
5355 }
5356
5357 48607 int32_t move = knockbackSpeed;
5358
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 48607 times.
94695 while(move>0)
5359 {
5360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48607 times.
48607 int32_t thismove = zc_min(8, move);
5361 48607 move -= thismove;
5362 48607 hitdir = (sclk>>8);
5363
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5936 times.
✓ Branch 2 taken 6261 times.
✓ Branch 3 taken 16156 times.
✓ Branch 4 taken 18597 times.
48607 switch(sclk>>8)
5364 {
5365 case up:
5366 5936 y-=thismove;
5367 5936 break;
5368
5369 case down:
5370 6261 y+=thismove;
5371 6261 break;
5372
5373 case left:
5374 16156 x-=thismove;
5375 16156 break;
5376
5377 case right:
5378 18597 x+=thismove;
5379 18597 break;
5380 }
5381
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 2519 times.
48607 if(!canmove(sclk>>8,(zfix)0,0,true))
5382 {
5383
3/3
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 1460 times.
✓ Branch 2 taken 4 times.
2519 switch(sclk>>8)
5384 {
5385 case up:
5386 case down:
5387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 if(y < 0)
5388 y = 0;
5389
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 865 times.
1055 else if((int32_t(y)&15) > 7)
5390 190 y=(int32_t(y)&0xF0)+16;
5391 else
5392 865 y=(int32_t(y)&0xF0);
5393
5394 1055 break;
5395
5396 case left:
5397 case right:
5398
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1459 times.
1460 if(x < 0)
5399 1 x = 0;
5400
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1027 times.
1459 else if((int32_t(x)&15) > 7)
5401 432 x=(int32_t(x)&0xF0)+16;
5402 else
5403 1027 x=(int32_t(x)&0xF0);
5404
5405 1460 break;
5406 }
5407
5408 2519 sclk=0;
5409 2519 clk3=0;
5410 2519 break;
5411 }
5412 }
5413
5414
2/2
✓ Branch 0 taken 44810 times.
✓ Branch 1 taken 3797 times.
48607 if((sclk&255)==0)
5415 {
5416 //hitdir = -1;
5417 3797 sclk=0;
5418 3797 }
5419 48607 return 2;
5420 9374767 }
5421
5422 bool enemy::can_slide()
5423 {
5424 if(sclk==0 || (hp<=0 && !immortal))
5425 return false;
5426
5427 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5428 {
5429 return false;
5430 }
5431
5432 return true;
5433 }
5434
5435 bool enemy::fslide()
5436 {
5437 if(sclk==0 || (hp<=0 && !immortal))
5438 return false;
5439
5440 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5441 {
5442 sclk=0;
5443 return false;
5444 }
5445
5446 --sclk;
5447
5448 switch(sclk>>8)
5449 {
5450 case up:
5451 if(y<=16)
5452 {
5453 sclk=0;
5454 return false;
5455 }
5456
5457 break;
5458
5459 case down:
5460 if(y>=160)
5461 {
5462 sclk=0;
5463 return false;
5464 }
5465
5466 break;
5467
5468 case left:
5469 if(x<=16)
5470 {
5471 sclk=0;
5472 return false;
5473 }
5474
5475 break;
5476
5477 case right:
5478 if(x>=240)
5479 {
5480 sclk=0;
5481 return false;
5482 }
5483
5484 break;
5485 }
5486 hitdir = (sclk>>8);
5487 switch(sclk>>8)
5488 {
5489 case up:
5490 y-=4;
5491 break;
5492
5493 case down:
5494 y+=4;
5495 break;
5496
5497 case left:
5498 x-=4;
5499 break;
5500
5501 case right:
5502 x+=4;
5503 break;
5504 }
5505
5506 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5507 {
5508 switch(sclk>>8)
5509 {
5510 case up:
5511 case down:
5512 if((int32_t(y)&15) > 7)
5513 y=(int32_t(y)&0xF0)+16;
5514 else
5515 y=(int32_t(y)&0xF0);
5516
5517 break;
5518
5519 case left:
5520 case right:
5521 if((int32_t(x)&15) > 7)
5522 x=(int32_t(x)&0xF0)+16;
5523 else
5524 x=(int32_t(x)&0xF0);
5525
5526 break;
5527 }
5528
5529 sclk=0;
5530 clk3=0;
5531 }
5532
5533 if((sclk&255)==0)
5534 sclk=0;
5535
5536 return true;
5537 }
5538
5539 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5540 {
5541 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5542 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5543 bool ret = sprite::knockback(time, dir, speed);
5544 if(ret) sclk = 0; //kill engine knockback if interrupted
5545 //! Perhaps also set hitdir here, if needed for timing? -Z
5546 return ret;
5547 }
5548
5549 21147337 bool enemy::runKnockback()
5550 {
5551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21147337 times.
21147337 if((script_knockback_clk&0xFF)==0)
5552 {
5553 21147337 script_knockback_clk = 0;
5554 21147337 return false;
5555 }
5556 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5557 {
5558 return false;
5559 }
5560 int32_t move = script_knockback_speed;
5561 int32_t kb_dir = script_knockback_clk>>8;
5562 --script_knockback_clk;
5563
5564 while(move>0)
5565 {
5566 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5567 move -= thismove;
5568 hitdir = kb_dir;
5569 switch(kb_dir)
5570 {
5571 case r_up:
5572 case l_up:
5573 case up:
5574 y-=thismove;
5575 break;
5576
5577 case r_down:
5578 case l_down:
5579 case down:
5580 y+=thismove;
5581 break;
5582 }
5583 switch(kb_dir)
5584 {
5585 case l_up:
5586 case l_down:
5587 case left:
5588 x-=thismove;
5589 break;
5590
5591 case r_up:
5592 case r_down:
5593 case right:
5594 x+=thismove;
5595 break;
5596 }
5597 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5598 {
5599 if(!canmove(kb_dir,(zfix)0,0,true))
5600 {
5601 script_knockback_clk=0;
5602 clk3=0;
5603 //Fix to grid
5604 switch(kb_dir)
5605 {
5606 case up:
5607 case down:
5608 break;
5609 default:
5610 if(x < 0)
5611 x = 0;
5612 else if((int32_t(x)&15) > 7)
5613 x=(int32_t(x)&0xF0)+16;
5614 else
5615 x=(int32_t(x)&0xF0);
5616 break;
5617 }
5618 switch(kb_dir)
5619 {
5620 case left:
5621 case right:
5622 break;
5623 default:
5624 if(y < 0)
5625 y = 0;
5626 else if((int32_t(y)&15) > 7)
5627 y=(int32_t(y)&0xF0)+16;
5628 else
5629 y=(int32_t(y)&0xF0);
5630 break;
5631 }
5632 break;
5633 }
5634 }
5635 else
5636 {
5637 if(!scr_canplace(x,y,0,true))
5638 {
5639 script_knockback_clk=0;
5640 clk3=0;
5641 //Fix to grid
5642 if (OFFGRID_ENEMY)
5643 {
5644 switch(kb_dir)
5645 {
5646 case up:
5647 case down:
5648 break;
5649 default:
5650 if(x < 0)
5651 x = 0;
5652 else if((int32_t(x)&7) > 3)
5653 x=(int32_t(x)&0xF8)+8;
5654 else
5655 x=(int32_t(x)&0xF8);
5656 break;
5657 }
5658 switch(kb_dir)
5659 {
5660 case left:
5661 case right:
5662 break;
5663 default:
5664 if(y < 0)
5665 y = 0;
5666 else if((int32_t(y)&7) > 3)
5667 y=(int32_t(y)&0xF8)+8;
5668 else
5669 y=(int32_t(y)&0xF8);
5670 break;
5671 }
5672 }
5673 else
5674 {
5675 switch(kb_dir)
5676 {
5677 case up:
5678 case down:
5679 break;
5680 default:
5681 if(x < 0)
5682 x = 0;
5683 else if((int32_t(x)&15) > 7)
5684 x=(int32_t(x)&0xF0)+16;
5685 else
5686 x=(int32_t(x)&0xF0);
5687 break;
5688 }
5689 switch(kb_dir)
5690 {
5691 case left:
5692 case right:
5693 break;
5694 default:
5695 if(y < 0)
5696 y = 0;
5697 else if((int32_t(y)&15) > 7)
5698 y=(int32_t(y)&0xF0)+16;
5699 else
5700 y=(int32_t(y)&0xF0);
5701 break;
5702 }
5703 }
5704 break;
5705 }
5706
5707 }
5708 }
5709 return true;
5710 21147337 }
5711 // changes enemy's direction, checking restrictions
5712 // rate: 0 = no random changes, 16 = always random change
5713 // homing: 0 = none, 256 = always
5714 // grumble 0 = none, 4 = strongest appetite
5715 306148 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5716 {
5717 306148 int32_t ndir=-1;
5718
5719
4/4
✓ Branch 0 taken 73847 times.
✓ Branch 1 taken 232301 times.
✓ Branch 2 taken 26089 times.
✓ Branch 3 taken 47758 times.
306148 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5720 {
5721 47758 int32_t i = Lwpns.idFirst(wBait);
5722
1/2
✓ Branch 0 taken 47758 times.
✗ Branch 1 not taken.
47758 if(i >= 0) //idfirst returns -1 if it can't find any
5723 {
5724 weapon *w = (weapon*)Lwpns.spr(i);
5725 if (get_qr(qr_FIND_CLOSEST_BAIT))
5726 {
5727 int32_t currentrange;
5728 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5729 else currentrange = -1;
5730 int curid = i;
5731 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5732 for(; i<Lwpns.Count(); ++i)
5733 {
5734 weapon *lw = (weapon*)Lwpns.spr(i);
5735 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5736 {
5737 currentrange = distance(x, y, lw->x, lw->y);
5738 curid = i;
5739 }
5740 }
5741 i = curid;
5742 if (currentrange == -1) i = -1;
5743 }
5744 else
5745 {
5746 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5747 }
5748 if (i >= 0)
5749 {
5750 int32_t bx = Lwpns.spr(i)->x;
5751 int32_t by = Lwpns.spr(i)->y;
5752
5753 if(abs(int32_t(y)-by)>14)
5754 {
5755 ndir = (by<y) ? up : down;
5756 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5757 if(canmove(ndir,special,false))
5758 {
5759 dir=ndir;
5760 return;
5761 }
5762 }
5763
5764 ndir = (bx<x) ? left : right;
5765 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5766 if(canmove(ndir,special,false))
5767 {
5768 dir=ndir;
5769 return;
5770 }
5771 }
5772 }
5773 47758 }
5774
5775
2/2
✓ Branch 0 taken 209215 times.
✓ Branch 1 taken 96933 times.
306148 if((zc_oldrand()&255)<abs(newhoming))
5776 {
5777 96933 ndir = lined_up(8,false);
5778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96933 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96933 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5779
4/4
✓ Branch 0 taken 25541 times.
✓ Branch 1 taken 71392 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 22185 times.
96933 if(ndir>=0 && canmove(ndir,special,false))
5780 {
5781 22185 dir=ndir;
5782 22185 return;
5783 }
5784 74748 }
5785
5786 283963 int32_t i=0;
5787
5788
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 634582 times.
635839 for(; i<32; i++)
5789 {
5790 634582 int32_t r=zc_oldrand();
5791
5792
2/2
✓ Branch 0 taken 194873 times.
✓ Branch 1 taken 439709 times.
634582 if((r&15)<newrate)
5793 194873 ndir=(r>>4)&3;
5794 else
5795 439709 ndir=dir;
5796
5797
2/2
✓ Branch 0 taken 351876 times.
✓ Branch 1 taken 282706 times.
634582 if(canmove(ndir,special,false))
5798 282706 break;
5799 351876 }
5800
5801
2/2
✓ Branch 0 taken 282706 times.
✓ Branch 1 taken 1257 times.
284392 if(i==32)
5802 {
5803
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 429 times.
3999 for(ndir=0; ndir<4; ndir++)
5804 {
5805
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 828 times.
3570 if(canmove(ndir,special,false))
5806 828 goto ok;
5807 2742 }
5808
5809
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 369 times.
429 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5810 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5811 429 }
5812
5813 ok:
5814 283963 dir = ndir;
5815 306148 }
5816
5817 1092 void enemy::newdir()
5818 {
5819 1092 newdir(4,0,spw_none);
5820 1092 }
5821
5822 zfix enemy::distance_left()
5823 {
5824 int32_t a2=x.getInt();
5825 int32_t b2=y.getInt();
5826
5827 switch(dir)
5828 {
5829 case up:
5830 return (zfix)(b2&0xF);
5831
5832 case down:
5833 return (zfix)(16-(b2&0xF));
5834
5835 case left:
5836 return (zfix)(a2&0xF);
5837
5838 case right:
5839 return (zfix)(16-(a2&0xF));
5840 }
5841
5842 return (zfix)0;
5843 }
5844
5845 // keeps walking around
5846 226860 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5847 {
5848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226860 times.
226860 if(slide())
5849 return;
5850
5851
8/12
✓ Branch 0 taken 224557 times.
✓ Branch 1 taken 2303 times.
✓ Branch 2 taken 224557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222559 times.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 222559 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 222559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 222559 times.
226860 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5852 4301 return;
5853
5854
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 207187 times.
222559 if(clk3<=0)
5855 {
5856 15372 fix_coords(true);
5857 15372 newdir(newrate,newhoming,special);
5858
5859
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(step==0)
5860 clk3=0;
5861 else
5862 15372 clk3=int32_t(16.0/step);
5863 15372 }
5864
2/2
✓ Branch 0 taken 207166 times.
✓ Branch 1 taken 21 times.
207187 else if(scored)
5865 {
5866 21 dir^=1;
5867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5868 else clk3=32767;
5869 21 }
5870
5871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222559 times.
222559 if (step != 0) --clk3;
5872 222559 move(step);
5873 226860 }
5874
5875 void enemy::constant_walk()
5876 {
5877 constant_walk(4,0,spw_none);
5878 }
5879
5880 18230 int32_t enemy::pos(int32_t newx,int32_t newy)
5881 {
5882 18230 return (newy<<8)+newx;
5883 }
5884
5885 // for variable step rates
5886 234267 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5887 {
5888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
234267 if(slide())
5889 return;
5890
5891
10/14
✓ Branch 0 taken 234267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228560 times.
✓ Branch 5 taken 5707 times.
✓ Branch 6 taken 221271 times.
✓ Branch 7 taken 7289 times.
✓ Branch 8 taken 200047 times.
✓ Branch 9 taken 21224 times.
✓ Branch 10 taken 200047 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200047 times.
✗ Branch 13 not taken.
234267 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5892 34220 return;
5893
5894 200047 zfix dx = (zfix)0;
5895 200047 zfix dy = (zfix)0;
5896
5897
5/9
✓ Branch 0 taken 43624 times.
✓ Branch 1 taken 44366 times.
✓ Branch 2 taken 53763 times.
✓ Branch 3 taken 56539 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1755 times.
200047 switch(dir)
5898 {
5899 case 8:
5900 case up:
5901 43624 dy-=step;
5902 43624 break;
5903
5904 case 12:
5905 case down:
5906 44366 dy+=step;
5907 44366 break;
5908
5909 case 14:
5910 case left:
5911 53763 dx-=step;
5912 53763 break;
5913
5914 case 10:
5915 case right:
5916 56539 dx+=step;
5917 56539 break;
5918
5919 case 15:
5920 case l_up:
5921 dx-=step;
5922 dy-=step;
5923 break;
5924
5925 case 9:
5926 case r_up:
5927 dx+=step;
5928 dy-=step;
5929 break;
5930
5931 case 13:
5932 case l_down:
5933 dx-=step;
5934 dy+=step;
5935 break;
5936
5937 case 11:
5938 case r_down:
5939 dx+=step;
5940 dy+=step;
5941 break;
5942 }
5943
5944
8/8
✓ Branch 0 taken 95284 times.
✓ Branch 1 taken 104763 times.
✓ Branch 2 taken 12002 times.
✓ Branch 3 taken 83282 times.
✓ Branch 4 taken 5443 times.
✓ Branch 5 taken 6559 times.
✓ Branch 6 taken 193819 times.
✓ Branch 7 taken 6228 times.
200047 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5945 194604 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5946 {
5947 6228 fix_coords();
5948 6228 newdir(newrate,newhoming,special);
5949 6228 clk3=pos(x,y);
5950 6228 }
5951
5952 200047 move(step);
5953 234267 }
5954
5955 // pauses for a while after it makes a complete move (to a new square)
5956 7484571 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5957 {
5958
4/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 7442764 times.
✓ Branch 2 taken 33602 times.
✓ Branch 3 taken 8205 times.
7484571 if(sclk && clk2)
5959 {
5960 8205 clk3=0;
5961 8205 }
5962
5963
11/14
✓ Branch 0 taken 7447681 times.
✓ Branch 1 taken 36890 times.
✓ Branch 2 taken 7447681 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7447681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7144870 times.
✓ Branch 7 taken 302811 times.
✓ Branch 8 taken 7018079 times.
✓ Branch 9 taken 126791 times.
✓ Branch 10 taken 7016307 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7016307 times.
7484571 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5964 {
5965 468264 return;
5966 }
5967
5968
2/2
✓ Branch 0 taken 1420795 times.
✓ Branch 1 taken 5595512 times.
7016307 if(clk2>0)
5969 {
5970 1420795 --clk2;
5971 1420795 return;
5972 }
5973
5974
2/2
✓ Branch 0 taken 243540 times.
✓ Branch 1 taken 5351972 times.
5595512 if(clk3<=0)
5975 {
5976 243540 fix_coords(true);
5977 243540 newdir(newrate,newhoming,special);
5978 243540 clk3=int32_t(16.0/step);
5979
2/2
✓ Branch 0 taken 243480 times.
✓ Branch 1 taken 60 times.
243540 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243540 times.
243540 if(clk2<0)
5981 {
5982 clk2=0;
5983 }
5984
2/2
✓ Branch 0 taken 35125 times.
✓ Branch 1 taken 208415 times.
243540 else if((zc_oldrand()&15)<newhrate)
5985 {
5986 35125 clk2=haltcnt;
5987 35125 return;
5988 }
5989 208415 }
5990
2/2
✓ Branch 0 taken 5350488 times.
✓ Branch 1 taken 1484 times.
5351972 else if(scored)
5991 {
5992 1484 dir^=1;
5993
5994
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1483 times.
1484 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5995 1 else clk3=32767;
5996 1484 }
5997
5998
2/2
✓ Branch 0 taken 37087 times.
✓ Branch 1 taken 5523300 times.
5560387 if (step != 0) --clk3;
5999 5560387 move(step);
6000 7484571 }
6001
6002 // 8-directional movement, aligns to 8 pixels
6003 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
6004 {
6005 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6006 return;
6007
6008 if(clk3<=0)
6009 {
6010 newdir_8(newrate,newhoming,special);
6011 clk3=int32_t(8.0/step);
6012 if (step == 0) clk3 = 32767;
6013 }
6014
6015 if (step != 0) --clk3;
6016 move(step);
6017 }
6018 // 8-directional movement, aligns to 8 pixels
6019 84876 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6020 {
6021
6/12
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84876 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84876 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84876 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84876 times.
84876 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6022 return;
6023
6024
2/2
✓ Branch 0 taken 78734 times.
✓ Branch 1 taken 6142 times.
84876 if(clk3<=0)
6025 {
6026 6142 newdir_8(newrate,newhoming,special);
6027 6142 clk3=int32_t(8.0/step);
6028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6142 times.
6142 if (step == 0) clk3 = 32767;
6029 6142 }
6030
6031
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if (step != 0) --clk3;
6032 84876 move(step);
6033 84876 }
6034
6035 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6036 {
6037 if(clk<0 || dying || stunclk || watch || frozenclock)
6038 return;
6039
6040 if(!canmove(dir,step,special,false))
6041 clk3=0;
6042
6043 if(clk2>0)
6044 {
6045 --clk2;
6046 return;
6047 }
6048
6049 if(clk3<=0)
6050 {
6051 newdir_8(newrate,newhoming,special);
6052 clk3=newclk;
6053
6054 if(clk2<0)
6055 {
6056 clk2=0;
6057 }
6058 else if((zc_oldrand()&15)<newhrate)
6059 {
6060 newdir_8(newrate,newhoming,special);
6061 clk2=haltcnt;
6062 return;
6063 }
6064 }
6065
6066 --clk3;
6067 move(step);
6068 }
6069
6070 // 8-directional movement, no alignment
6071 2513985 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6072 {
6073
9/12
✓ Branch 0 taken 2408462 times.
✓ Branch 1 taken 105523 times.
✓ Branch 2 taken 2408462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2386969 times.
✓ Branch 5 taken 21493 times.
✓ Branch 6 taken 2377143 times.
✓ Branch 7 taken 9826 times.
✓ Branch 8 taken 2377143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2377143 times.
2513985 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6074 136842 return;
6075
6076
2/2
✓ Branch 0 taken 2360249 times.
✓ Branch 1 taken 16894 times.
2377143 if(!canmove(dir,step,special,false))
6077 16894 clk3=0;
6078
6079
2/2
✓ Branch 0 taken 2075350 times.
✓ Branch 1 taken 301793 times.
2377143 if(clk3<=0)
6080 {
6081 301793 newdir_8(newrate,newhoming,special);
6082 301793 clk3=newclk;
6083 301793 }
6084
6085 2377143 --clk3;
6086 2377143 move(step);
6087 2513985 }
6088
6089 // same as above but with variable enemy size
6090 52535 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6091 {
6092
8/12
✓ Branch 0 taken 51768 times.
✓ Branch 1 taken 767 times.
✓ Branch 2 taken 51768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51768 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51717 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 51717 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 51717 times.
52535 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6093 818 return;
6094
6095
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 517 times.
51717 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6096 517 clk3=0;
6097
6098
2/2
✓ Branch 0 taken 48239 times.
✓ Branch 1 taken 3478 times.
51717 if(clk3<=0)
6099 {
6100 3478 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6101 3478 clk3=newclk;
6102 3478 }
6103
6104 51717 --clk3;
6105 51717 move(step);
6106 52535 }
6107
6108 // the variable speed floater movement
6109 // ms is max speed
6110 // ss is step speed
6111 // s is step count
6112 // p is pause count
6113 // g is graduality :)
6114 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6115 2107695 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6116 {
6117 2107695 ++clk2;
6118 2107695 byte over_pit = overpit(this);
6119
6120
4/4
✓ Branch 0 taken 424954 times.
✓ Branch 1 taken 1682741 times.
✓ Branch 2 taken 424687 times.
✓ Branch 3 taken 267 times.
2107695 if(dmisc1 && over_pit) p = 0;
6121
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36911 times.
✓ Branch 2 taken 849849 times.
✓ Branch 3 taken 1135402 times.
✓ Branch 4 taken 85533 times.
2107695 switch(movestatus)
6122 {
6123 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6124 //! if the conditions prevent it, we jump back to case 2.
6125 case 0: // paused
6126
2/2
✓ Branch 0 taken 36222 times.
✓ Branch 1 taken 689 times.
36911 if(clk2>=p)
6127 {
6128 689 movestatus=1;
6129 689 clk2=0;
6130 689 }
6131
6132 36911 break;
6133
6134 case 1: // speeding up
6135
1/2
✓ Branch 0 taken 849849 times.
✗ Branch 1 not taken.
849849 if (s >= 0)
6136 {
6137
2/2
✓ Branch 0 taken 844313 times.
✓ Branch 1 taken 5536 times.
849849 if(clk2<g*s)
6138 {
6139
2/2
✓ Branch 0 taken 790189 times.
✓ Branch 1 taken 54124 times.
844313 if(!((clk2-1)%g))
6140 54124 step+=ss;
6141 844313 }
6142 else
6143 {
6144 5536 movestatus=2;
6145 5536 clk2=0;
6146 }
6147 849849 }
6148 else
6149 {
6150 if(step < ms)
6151 {
6152 if(!((clk2-1)%g))
6153 {
6154 step+=ss;
6155 if (step >= ms) step = ms;
6156 }
6157 }
6158 else
6159 {
6160 step = ms;
6161 movestatus=2;
6162 clk2=0;
6163 }
6164 }
6165
6166 849849 break;
6167
6168 case 2: // normal
6169 1135402 step=ms;
6170
6171
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1135402 times.
✓ Branch 2 taken 237381 times.
✓ Branch 3 taken 898021 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 898021 times.
✓ Branch 6 taken 896841 times.
✓ Branch 7 taken 1180 times.
1135402 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6172 {
6173
1/2
✓ Branch 0 taken 1180 times.
✗ Branch 1 not taken.
1180 if (s >= 0) step=ss*s;
6174 else step=ms;
6175 1180 movestatus=3;
6176 1180 clk2=0;
6177 1180 }
6178
6179 1135402 break;
6180
6181 case 3: // slowing down
6182
1/2
✓ Branch 0 taken 85533 times.
✗ Branch 1 not taken.
85533 if (s >= 0)
6183 {
6184
2/2
✓ Branch 0 taken 84707 times.
✓ Branch 1 taken 826 times.
85533 if(clk2<=g*s)
6185 {
6186 { //don't slow down over pits
6187
6188
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84695 times.
84707 if(over_pit)
6189 {
6190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
6191 {
6192 step=ms;
6193 }
6194 12 }
6195 else //can slow down
6196 {
6197
4/4
✓ Branch 0 taken 5242 times.
✓ Branch 1 taken 79453 times.
✓ Branch 2 taken 4970 times.
✓ Branch 3 taken 272 times.
84695 if(!(clk2%g) && !dmisc1)
6198 4970 step-=ss;
6199 }
6200 }
6201
6202
6203 84707 }
6204 else
6205 {
6206 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6207 //this doesn't help keese, as they have a z of 0.
6208 //they always nee to run this check.
6209 {
6210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
826 if(over_pit &&!dmisc1)
6211 {
6212 --clk2; //if over a pit, don't land, and revert clock change
6213 }
6214 else //can land safely
6215 {
6216 826 movestatus=0;
6217
3/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
826 if(dmisc1&&!over_pit)
6218 468 step=0;
6219 826 clk2=0;
6220 }
6221 }
6222
6223 }
6224 85533 }
6225 else
6226 {
6227 if(step > 0)
6228 {
6229 if(over_pit)
6230 {
6231 if(dmisc1)
6232 {
6233 step=ms;
6234 }
6235 }
6236 else //can slow down
6237 {
6238 if(!(clk2%g))
6239 step-=ss;
6240 }
6241 }
6242 else
6243 {
6244 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6245 //this doesn't help keese, as they have a z of 0.
6246 //they always nee to run this check.
6247 if(over_pit)
6248 {
6249 step+=ss; //if over a pit, don't land, and revert clock change
6250 }
6251 else //can land safely
6252 {
6253 movestatus=0;
6254 step=0;
6255 clk2=0;
6256 }
6257 }
6258 }
6259
6260 85533 break;
6261 }
6262
6263
2/2
✓ Branch 0 taken 1139758 times.
✓ Branch 1 taken 967937 times.
2107695 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6264 2107695 }
6265
6266 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6267 {
6268 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6269 }
6270
6271 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6272 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6273 505582 int32_t enemy::lined_up(int32_t range, bool dir8)
6274 {
6275 505582 int32_t lx = Hero.getX();
6276 505582 int32_t ly = Hero.getY();
6277
6278
2/2
✓ Branch 0 taken 19792 times.
✓ Branch 1 taken 485790 times.
505582 if(abs(lx-int32_t(x))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 7911 times.
✓ Branch 1 taken 11881 times.
19792 if(ly<y)
6281 {
6282 7911 return up;
6283 }
6284
6285 11881 return down;
6286 }
6287
6288
2/2
✓ Branch 0 taken 23667 times.
✓ Branch 1 taken 462123 times.
485790 if(abs(ly-int32_t(y))<=range)
6289 {
6290
2/2
✓ Branch 0 taken 12187 times.
✓ Branch 1 taken 11480 times.
23667 if(lx<x)
6291 {
6292 12187 return left;
6293 }
6294
6295 11480 return right;
6296 }
6297
6298
2/2
✓ Branch 0 taken 94748 times.
✓ Branch 1 taken 367375 times.
462123 if(dir8)
6299 {
6300
2/2
✓ Branch 0 taken 130299 times.
✓ Branch 1 taken 237076 times.
367375 if(abs(lx-x)-abs(ly-y)<=range)
6301 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6302 {
6303
2/2
✓ Branch 0 taken 55233 times.
✓ Branch 1 taken 75066 times.
130299 if(ly<y)
6304 {
6305
2/2
✓ Branch 0 taken 32006 times.
✓ Branch 1 taken 23227 times.
55233 if(lx<x)
6306 {
6307 32006 return l_up;
6308 }
6309 else
6310 {
6311 23227 return r_up;
6312 }
6313 }
6314 else
6315 {
6316
2/2
✓ Branch 0 taken 38204 times.
✓ Branch 1 taken 36862 times.
75066 if(lx<x)
6317 {
6318 36862 return l_down;
6319 }
6320 else
6321 {
6322 38204 return r_down;
6323 }
6324 }
6325 }
6326 237076 }
6327
6328 331824 return -1;
6329 505582 }
6330
6331 // returns true if Hero is within 'range' pixels of the enemy
6332 13988 bool enemy::HeroInRange(int32_t range)
6333 {
6334 13988 int32_t lx = Hero.getX();
6335 13988 int32_t ly = Hero.getY();
6336
2/2
✓ Branch 0 taken 11733 times.
✓ Branch 1 taken 2255 times.
13988 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6337 }
6338
6339 // place the enemy in line with Hero (red wizzrobes)
6340 2334 void enemy::place_on_axis(bool floater, bool solid_ok)
6341 {
6342
6/6
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 411 times.
✓ Branch 2 taken 2129 times.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 1718 times.
✓ Branch 5 taken 411 times.
2334 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6343
6/6
✓ Branch 0 taken 1958 times.
✓ Branch 1 taken 376 times.
✓ Branch 2 taken 1980 times.
✓ Branch 3 taken 354 times.
✓ Branch 4 taken 1604 times.
✓ Branch 5 taken 376 times.
2334 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6344 2334 int32_t pos2=zc_oldrand()%23;
6345 2334 int32_t tried=0;
6346 2334 bool last_resort,placed=false;
6347
6348
6349 2334 do
6350 {
6351
2/2
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1712 times.
4131 if(pos2<14)
6352 {
6353 2419 x=(pos2<<4)+16;
6354 2419 y=ly;
6355 2419 }
6356 else
6357 {
6358 1712 x=lx;
6359 1712 y=((pos2-14)<<4)+16;
6360 }
6361
6362 // Don't commit to a last resort if position is out of bounds.
6363
6/6
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 3808 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 127 times.
✓ Branch 5 taken 3681 times.
4131 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6364
6365
4/4
✓ Branch 0 taken 2148 times.
✓ Branch 1 taken 1983 times.
✓ Branch 2 taken 3739 times.
✓ Branch 3 taken 1801 times.
4131 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6366 {
6367 // Red Wizzrobes should be able to appear on water, but not other
6368 // solid combos; however, they could appear on solid combos in 2.10,
6369 // and some quests depend on that.
6370
4/4
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 3582 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 2334 times.
5722 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6371 5722 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6372 2334 placed=true;
6373 5722 }
6374
6375
3/6
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3230 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1797 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5027 if(!placed && tried>=22 && last_resort)
6376 {
6377 placed=true;
6378 }
6379
6380 5027 ++tried;
6381 5027 pos2=(pos2+3)%23;
6382
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3230 times.
5027 }
6383 5027 while(!placed);
6384
6385
2/2
✓ Branch 0 taken 2376 times.
✓ Branch 1 taken 854 times.
3230 if(y==ly)
6386 2376 dir=(x<lx)?right:left;
6387 else
6388 854 dir=(y<ly)?down:up;
6389
6390 3230 clk2=tried;
6391 3230 }
6392
6393 10524416 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6394 {
6395 10524416 int32_t t = o_tile;
6396 10524416 int32_t b = o_tile;
6397
6398 // Darknuts, but also Wizzrobes and Wallmasters
6399
3/4
✓ Branch 0 taken 3963465 times.
✓ Branch 1 taken 6178051 times.
✓ Branch 2 taken 382900 times.
✗ Branch 3 not taken.
10524416 switch(family)
6400 {
6401 case eeWALK:
6402
5/6
✓ Branch 0 taken 373692 times.
✓ Branch 1 taken 5804359 times.
✓ Branch 2 taken 264807 times.
✓ Branch 3 taken 108885 times.
✓ Branch 4 taken 264807 times.
✗ Branch 5 not taken.
6178051 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6403 {
6404 264807 tile=s_tile;
6405 264807 t=s_tile;
6406 264807 b=s_tile;
6407 264807 }
6408
6409 6178051 break;
6410
6411 case eeTRAP:
6412
4/6
✓ Branch 0 taken 141238 times.
✓ Branch 1 taken 241662 times.
✓ Branch 2 taken 141238 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 141238 times.
382900 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
6413 {
6414 141238 tile=s_tile;
6415 141238 t=s_tile;
6416 141238 b=s_tile;
6417 141238 }
6418
6419 382900 break;
6420
6421 case eeSPINTILE:
6422 if(misc>=96 && do_animation)
6423 {
6424 tile=o_tile+frames*ndir;
6425 t=tile;
6426 }
6427
6428 break;
6429 }
6430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10524416 times.
10524416 if ( do_animation )
6431 {
6432
4/6
✓ Branch 0 taken 163042 times.
✓ Branch 1 taken 10361374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266817 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10094557 times.
10524416 if(ndir!=0) switch(frames)
6433 {
6434 case 2:
6435 266817 tiledir_small(dir,ndir==4);
6436 266817 break;
6437
6438 case 3:
6439 tiledir_three(dir);
6440 break;
6441
6442 case 4:
6443 10094557 tiledir(dir,ndir==4);
6444 10094557 break;
6445 10361374 }
6446
6447
2/2
✓ Branch 0 taken 6178051 times.
✓ Branch 1 taken 4346365 times.
10524416 if(family==eeWALK)
6448
6/6
✓ Branch 0 taken 4911333 times.
✓ Branch 1 taken 1266718 times.
✓ Branch 2 taken 4638452 times.
✓ Branch 3 taken 1539599 times.
✓ Branch 4 taken 1215347 times.
✓ Branch 5 taken 324252 times.
6178051 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6449 else
6450 4346365 tile+=f4;
6451 10524416 }
6452 10524416 return b;
6453 }
6454
6455 void enemy::tiledir_three(int32_t ndir)
6456 {
6457 if ( !do_animation ) return;
6458 flip=0;
6459
6460 switch(ndir)
6461 {
6462 case right:
6463 tile+=3;
6464 [[fallthrough]];
6465
6466 case left:
6467 tile+=3;
6468 [[fallthrough]];
6469
6470 case down:
6471 tile+=3;
6472 [[fallthrough]];
6473
6474 case up:
6475 break;
6476 }
6477 }
6478
6479 266817 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6480 {
6481
1/2
✓ Branch 0 taken 266817 times.
✗ Branch 1 not taken.
266817 if ( !do_animation ) return;
6482 266817 flip=0;
6483
6484
8/9
✓ Branch 0 taken 53728 times.
✓ Branch 1 taken 54633 times.
✓ Branch 2 taken 67625 times.
✓ Branch 3 taken 71117 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
266817 switch(ndir)
6485 {
6486 case 8:
6487 case up:
6488 53728 break;
6489
6490 case 12:
6491 case down:
6492 54633 tile+=2;
6493 54633 break;
6494
6495 case 14:
6496 case left:
6497 67625 tile+=4;
6498 67625 break;
6499
6500 case 10:
6501 case right:
6502 71117 tile+=6;
6503 71117 break;
6504
6505 case 9:
6506 case r_up:
6507
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6508 5706 break;
6509
6510 tile+=10;
6511 break;
6512
6513 case 11:
6514 case r_down:
6515
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6516 5154 tile+=2;
6517 else
6518 tile+=14;
6519
6520 5154 break;
6521
6522 case 13:
6523 case l_down:
6524
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6525 4872 tile+=2;
6526 else
6527 tile+=12;
6528
6529 4872 break;
6530
6531 case 15:
6532 case l_up:
6533
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6534 3982 break;
6535
6536 tile+=8;
6537 break;
6538
6539 default:
6540 //dir=(zc_oldrand()*100)%8;
6541 //tiledir_small(dir);
6542 // flip=zc_oldrand()&3;
6543 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6544 break;
6545 }
6546 266817 }
6547
6548 11660468 void enemy::tiledir(int32_t ndir, bool fourdir)
6549 {
6550
1/2
✓ Branch 0 taken 11660468 times.
✗ Branch 1 not taken.
11660468 if ( !do_animation ) return;
6551 11660468 flip=0;
6552
6553
9/9
✓ Branch 0 taken 2359939 times.
✓ Branch 1 taken 2044242 times.
✓ Branch 2 taken 2781916 times.
✓ Branch 3 taken 2670926 times.
✓ Branch 4 taken 406885 times.
✓ Branch 5 taken 486841 times.
✓ Branch 6 taken 474500 times.
✓ Branch 7 taken 419015 times.
✓ Branch 8 taken 16204 times.
11660468 switch(ndir)
6554 {
6555 case 8:
6556 case up:
6557 2359939 break;
6558
6559 case 12:
6560 case down:
6561 2044242 tile+=4;
6562 2044242 break;
6563
6564 case 14:
6565 case left:
6566 2781916 tile+=8;
6567 2781916 break;
6568
6569 case 10:
6570 case right:
6571 2670926 tile+=12;
6572 2670926 break;
6573
6574 case 9:
6575 case r_up:
6576
2/2
✓ Branch 0 taken 57693 times.
✓ Branch 1 taken 349192 times.
406885 if(fourdir)
6577 57693 break;
6578 else
6579 349192 tile+=24;
6580
6581 349192 break;
6582
6583 case 11:
6584 case r_down:
6585
2/2
✓ Branch 0 taken 63504 times.
✓ Branch 1 taken 423337 times.
486841 if(fourdir)
6586 63504 tile+=4;
6587 else
6588 423337 tile+=32;
6589
6590 486841 break;
6591
6592 case 13:
6593 case l_down:
6594
2/2
✓ Branch 0 taken 66073 times.
✓ Branch 1 taken 408427 times.
474500 if(fourdir)
6595 66073 tile+=4;
6596 else
6597 408427 tile+=28;
6598
6599 474500 break;
6600
6601 case 15:
6602 case l_up:
6603
2/2
✓ Branch 0 taken 50160 times.
✓ Branch 1 taken 368855 times.
419015 if(fourdir)
6604 50160 break;
6605 else
6606 368855 tile+=20;
6607
6608 368855 break;
6609
6610 default:
6611 //dir=(zc_oldrand()*100)%8;
6612 //tiledir(dir);
6613 // flip=zc_oldrand()&3;
6614 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6615 16204 break;
6616 }
6617 11660468 }
6618
6619 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6620 {
6621
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
6622 3868 flip=0;
6623
6624
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6625 {
6626 case 8:
6627 case up:
6628 297 break;
6629
6630 case 12:
6631 case down:
6632 tile+=8;
6633 break;
6634
6635 case 14:
6636 case left:
6637 195 tile+=40;
6638 195 break;
6639
6640 case 10:
6641 case right:
6642 179 tile+=48;
6643 179 break;
6644
6645 case 9:
6646 case r_up:
6647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6648 break;
6649
6650 306 tile+=88;
6651 306 break;
6652
6653 case 11:
6654 case r_down:
6655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6656 tile+=8;
6657 else
6658 1235 tile+=128;
6659
6660 1235 break;
6661
6662 case 13:
6663 case l_down:
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6665 tile+=8;
6666 else
6667 1324 tile+=120;
6668
6669 1324 break;
6670
6671 case 15:
6672 case l_up:
6673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6674 break;
6675
6676 332 tile+=80;
6677 332 break;
6678
6679 default:
6680 //dir=(zc_oldrand()*100)%8;
6681 //tiledir_big(dir);
6682 // flip=zc_oldrand()&3;
6683 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6684 break;
6685 }
6686 3868 }
6687
6688 22903770 void enemy::update_enemy_frame()
6689 {
6690
3/4
✓ Branch 0 taken 22903628 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22903628 times.
22903770 if(fallclk||drownclk) return;
6691
1/2
✓ Branch 0 taken 22903628 times.
✗ Branch 1 not taken.
22903628 if (!do_animation)
6692 return;
6693
6694
3/4
✓ Branch 0 taken 152474 times.
✓ Branch 1 taken 22751154 times.
✓ Branch 2 taken 152474 times.
✗ Branch 3 not taken.
22903628 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6695
6696
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22903628 if(get_qr(qr_ANONE_NOANIM)
6697
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22903628 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22903628 && anim == aNONE && family != eeGUY)
6698 return;
6699
2/2
✓ Branch 0 taken 22522595 times.
✓ Branch 1 taken 381033 times.
22903628 int32_t newfrate = zc_max(frate,4);
6700 22903628 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6701 22903628 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6702
2/2
✓ Branch 0 taken 15605225 times.
✓ Branch 1 taken 7298403 times.
22903628 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6703 22903628 tile = o_tile;
6704 22903628 int32_t basetile = o_tile;
6705 22903628 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6706 22903628 bool ignore_extend = false;
6707
34/40
✓ Branch 0 taken 164903 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 37236 times.
✓ Branch 3 taken 1313148 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89141 times.
✓ Branch 7 taken 233641 times.
✓ Branch 8 taken 128056 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2773771 times.
✓ Branch 12 taken 41139 times.
✓ Branch 13 taken 50626 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 353574 times.
✓ Branch 16 taken 622431 times.
✓ Branch 17 taken 163042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 98223 times.
✓ Branch 20 taken 157529 times.
✓ Branch 21 taken 428287 times.
✓ Branch 22 taken 1050207 times.
✓ Branch 23 taken 934304 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 266817 times.
✓ Branch 26 taken 2408805 times.
✓ Branch 27 taken 3857795 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 399313 times.
✓ Branch 30 taken 912736 times.
✓ Branch 31 taken 614651 times.
✓ Branch 32 taken 161932 times.
✓ Branch 33 taken 1317852 times.
✓ Branch 34 taken 74670 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3483844 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 219227 times.
✓ Branch 39 taken 38974 times.
22903628 switch(anim)
6708 {
6709
6710 case aDONGO:
6711 {
6712 41139 int32_t fr = stunclk>0 ? 16 : 8;
6713
6714
6/6
✓ Branch 0 taken 39717 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 4800 times.
✓ Branch 3 taken 34917 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 3200 times.
41139 if(!dying && clk2>0 && clk2<=64)
6715 {
6716 // bloated
6717
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 1152 times.
✓ Branch 4 taken 768 times.
3200 switch(dir)
6718 {
6719 case up:
6720 832 tile+=9;
6721 832 flip=0;
6722 832 xofs=0;
6723 832 dummy_int[1]=0; //no additional tiles
6724 832 break;
6725
6726 case down:
6727 448 tile+=7;
6728 448 flip=0;
6729 448 xofs=0;
6730 448 dummy_int[1]=0; //no additional tiles
6731 448 break;
6732
6733 case left:
6734 1152 flip=1;
6735 1152 tile+=4;
6736 1152 xofs=16;
6737 1152 dummy_int[1]=1; //second tile is next tile
6738 1152 break;
6739
6740 case right:
6741 768 flip=0;
6742 768 tile+=5;
6743 768 xofs=16;
6744 768 dummy_int[1]=-1; //second tile is previous tile
6745 768 break;
6746 }
6747 3200 }
6748
4/4
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 36517 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 783 times.
37939 else if(!dying || clk2>19)
6749 {
6750 // normal
6751
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7974 times.
✓ Branch 2 taken 8400 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 8568 times.
37156 switch(dir)
6752 {
6753 case up:
6754 7974 tile+=8;
6755 7974 flip=(clk&fr)?1:0;
6756 7974 xofs=0;
6757 7974 dummy_int[1]=0; //no additional tiles
6758 7974 break;
6759
6760 case down:
6761 8400 tile+=6;
6762 8400 flip=(clk&fr)?1:0;
6763 8400 xofs=0;
6764 8400 dummy_int[1]=0; //no additional tiles
6765 8400 break;
6766
6767 case left:
6768 12214 flip=1;
6769 12214 tile+=(clk&fr)?2:0;
6770 12214 xofs=16;
6771 12214 dummy_int[1]=1; //second tile is next tile
6772 12214 break;
6773
6774 case right:
6775 8568 flip=0;
6776 8568 tile+=(clk&fr)?3:1;
6777 8568 xofs=16;
6778 8568 dummy_int[1]=-1; //second tile is next tile
6779 8568 break;
6780 }
6781 37156 }
6782 }
6783 41139 break;
6784
6785 case aNEWDONGO:
6786 {
6787 50626 int32_t fr4=0;
6788
6789
6/6
✓ Branch 0 taken 48878 times.
✓ Branch 1 taken 1748 times.
✓ Branch 2 taken 3936 times.
✓ Branch 3 taken 44942 times.
✓ Branch 4 taken 1312 times.
✓ Branch 5 taken 2624 times.
50626 if(!dying && clk2>0 && clk2<=64)
6790 {
6791 // bloated
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(clk2>=0)
6793 {
6794 2624 fr4=3;
6795 2624 }
6796
6797
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 2009 times.
2624 if(clk2>=16)
6798 {
6799 2009 fr4=2;
6800 2009 }
6801
6802
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 1353 times.
2624 if(clk2>=32)
6803 {
6804 1353 fr4=1;
6805 1353 }
6806
6807
2/2
✓ Branch 0 taken 1927 times.
✓ Branch 1 taken 697 times.
2624 if(clk2>=48)
6808 {
6809 697 fr4=0;
6810 697 }
6811
6812
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1088 times.
2624 switch(dir)
6813 {
6814 case up:
6815 256 xofs=0;
6816 256 tile+=8+fr4;
6817 256 dummy_int[1]=0; //no additional tiles
6818 256 break;
6819
6820 case down:
6821 576 xofs=0;
6822 576 tile+=12+fr4;
6823 576 dummy_int[1]=0; //no additional tiles
6824 576 break;
6825
6826 case left:
6827 704 tile+=29+(2*fr4);
6828 704 xofs=16;
6829 704 dummy_int[1]=-1; //second tile is previous tile
6830 704 break;
6831
6832 case right:
6833 1088 tile+=49+(2*fr4);
6834 1088 xofs=16;
6835 1088 dummy_int[1]=-1; //second tile is previous tile
6836 1088 break;
6837 }
6838 2624 }
6839
4/4
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 46254 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 825 times.
48002 else if(!dying || clk2>19)
6840 {
6841 // normal
6842
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9019 times.
✓ Branch 2 taken 9429 times.
✓ Branch 3 taken 14024 times.
✓ Branch 4 taken 14705 times.
47177 switch(dir)
6843 {
6844 case up:
6845 9019 xofs=0;
6846 9019 tile+=((clk&12)>>2);
6847 9019 dummy_int[1]=0; //no additional tiles
6848 9019 break;
6849
6850 case down:
6851 9429 xofs=0;
6852 9429 tile+=4+((clk&12)>>2);
6853 9429 dummy_int[1]=0; //no additional tiles
6854 9429 break;
6855
6856 case left:
6857 14024 tile+=21+((clk&12)>>1);
6858 14024 xofs=16;
6859 14024 dummy_int[1]=-1; //second tile is previous tile
6860 14024 break;
6861
6862 case right:
6863 14705 flip=0;
6864 14705 tile+=41+((clk&12)>>1);
6865 14705 xofs=16;
6866 14705 dummy_int[1]=-1; //second tile is previous tile
6867 14705 break;
6868 }
6869 47177 }
6870 }
6871 50626 break;
6872
6873 case aDONGOBS:
6874 {
6875 818 int32_t fr4=0;
6876
6877
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
6878 {
6879 // bloated
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
6881 {
6882 128 fr4=3;
6883 128 }
6884
6885
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
6886 {
6887 98 fr4=2;
6888 98 }
6889
6890
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
6891 {
6892 66 fr4=1;
6893 66 }
6894
6895
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
6896 {
6897 34 fr4=0;
6898 34 }
6899
6900
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
6901 {
6902 case up:
6903 tile+=28+fr4;
6904 yofs+=8;
6905 dummy_int[1]=-20; //second tile change
6906 dummy_int[2]=0; //new xofs change
6907 dummy_int[3]=-16; //new xofs change
6908 break;
6909
6910 case down:
6911 tile+=12+fr4;
6912 yofs-=8;
6913 dummy_int[1]=20; //second tile change
6914 dummy_int[2]=0; //new xofs change
6915 dummy_int[3]=16; //new xofs change
6916 break;
6917
6918 case left:
6919 128 tile+=49+(2*fr4);
6920 128 xofs+=8;
6921 128 dummy_int[1]=-1; //second tile change
6922 128 dummy_int[2]=-16; //new xofs change
6923 128 dummy_int[3]=0; //new xofs change
6924 128 break;
6925
6926 case right:
6927 tile+=69+(2*fr4);
6928 xofs+=8;
6929 dummy_int[1]=-1; //second tile change
6930 dummy_int[2]=-16; //new xofs change
6931 dummy_int[3]=0; //new xofs change
6932 break;
6933 }
6934 128 }
6935
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
6936 {
6937 // normal
6938
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
6939 {
6940 case up:
6941 96 tile+=20+((clk&24)>>3);
6942 96 yofs+=8;
6943 96 dummy_int[1]=-20; //second tile change
6944 96 dummy_int[2]=0; //new xofs change
6945 96 dummy_int[3]=-16; //new xofs change
6946 96 break;
6947
6948 case down:
6949 129 tile+=4+((clk&24)>>3);
6950 129 yofs-=8;
6951 129 dummy_int[1]=20; //second tile change
6952 129 dummy_int[2]=0; //new xofs change
6953 129 dummy_int[3]=16; //new xofs change
6954 129 break;
6955
6956 case left:
6957 332 xofs=-8;
6958 332 tile+=40+((clk&24)>>2);
6959 332 dummy_int[1]=1; //second tile change
6960 332 dummy_int[2]=16; //new xofs change
6961 332 dummy_int[3]=0; //new xofs change
6962 332 break;
6963
6964 case right:
6965 97 tile+=60+((clk&24)>>2);
6966 97 xofs=-8;
6967 97 dummy_int[1]=1; //second tile change
6968 97 dummy_int[2]=16; //new xofs change
6969 97 dummy_int[3]=0; //new xofs change
6970 97 break;
6971 }
6972 654 }
6973 }
6974 818 break;
6975
6976 case aWIZZ:
6977 {
6978 // if(d->misc1)
6979
2/2
✓ Branch 0 taken 139048 times.
✓ Branch 1 taken 214526 times.
353574 if(dmisc1)
6980 {
6981
2/2
✓ Branch 0 taken 69275 times.
✓ Branch 1 taken 69773 times.
139048 if(clk&8)
6982 {
6983 69773 ++tile;
6984 69773 }
6985 139048 }
6986 else
6987 {
6988
2/2
✓ Branch 0 taken 107350 times.
✓ Branch 1 taken 107176 times.
214526 if(frame&4)
6989 {
6990 107176 ++tile;
6991 107176 }
6992 }
6993
6994
4/4
✓ Branch 0 taken 55328 times.
✓ Branch 1 taken 124116 times.
✓ Branch 2 taken 114795 times.
✓ Branch 3 taken 59335 times.
353574 switch(dir)
6995 {
6996 case 9:
6997 case 15:
6998 case up:
6999 55328 tile+=2;
7000 55328 break;
7001
7002 case down:
7003 59335 break;
7004
7005 case 13:
7006 case left:
7007 124116 flip=1;
7008 124116 break;
7009
7010 default:
7011 114795 flip=0;
7012 114795 break;
7013 }
7014 }
7015 353574 break;
7016
7017 case aNEWWIZZ:
7018 {
7019 622431 tiledir(dir,true);
7020
7021 // if(d->misc1) //walking wizzrobe
7022
2/2
✓ Branch 0 taken 330881 times.
✓ Branch 1 taken 291550 times.
622431 if(dmisc1) //walking wizzrobe
7023 {
7024
2/2
✓ Branch 0 taken 166270 times.
✓ Branch 1 taken 164611 times.
330881 if(clk&8)
7025 {
7026 164611 tile+=2;
7027 164611 }
7028
7029
2/2
✓ Branch 0 taken 165827 times.
✓ Branch 1 taken 165054 times.
330881 if(clk&4)
7030 {
7031 165054 tile+=1;
7032 165054 }
7033
7034
2/4
✓ Branch 0 taken 330881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 330881 times.
330881 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7035 {
7036
2/2
✓ Branch 0 taken 296297 times.
✓ Branch 1 taken 34584 times.
330881 if(dummy_int[1]>0)
7037 {
7038 34584 tile+=40;
7039 34584 }
7040 330881 }
7041 330881 }
7042 else
7043 {
7044
4/4
✓ Branch 0 taken 267218 times.
✓ Branch 1 taken 24332 times.
✓ Branch 2 taken 62854 times.
✓ Branch 3 taken 204364 times.
291550 if(dummy_bool[1]||dummy_bool[2])
7045 {
7046 87186 tile+=20;
7047
7048
2/2
✓ Branch 0 taken 24332 times.
✓ Branch 1 taken 62854 times.
87186 if(dummy_bool[2])
7049 {
7050 62854 tile+=20;
7051 62854 }
7052 87186 }
7053
7054 291550 tile+=((frame>>1)&3);
7055 }
7056 }
7057 622431 break;
7058
7059 case a3FRM:
7060 {
7061
2/2
✓ Branch 0 taken 38762 times.
✓ Branch 1 taken 124280 times.
163042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7062 }
7063 163042 break;
7064
7065 case a3FRM4DIR:
7066 {
7067 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7068 }
7069 break;
7070
7071 case aVIRE:
7072 {
7073
2/2
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 22222 times.
98223 if(dir==up)
7074 {
7075 22222 tile+=2;
7076 22222 }
7077
7078 98223 tile+=fx;
7079 }
7080 98223 break;
7081
7082 case aROPE:
7083 {
7084 164903 tile+=(1-fx);
7085 164903 flip = dir==left ? 1:0;
7086 }
7087 164903 break;
7088
7089 case aZORA:
7090 {
7091 int32_t dl;
7092
7093
2/2
✓ Branch 0 taken 33018 times.
✓ Branch 1 taken 124511 times.
157529 if(clk<36)
7094 {
7095 33018 dl=clk+5;
7096 33018 goto waves2;
7097 }
7098
7099
2/2
✓ Branch 0 taken 58613 times.
✓ Branch 1 taken 65898 times.
124511 if(clk<36+66)
7100
2/2
✓ Branch 0 taken 33479 times.
✓ Branch 1 taken 25134 times.
58613 tile=(dir==up)?o_tile+1:o_tile;
7101 else
7102 {
7103 65898 dl=clk-36-66;
7104 waves2:
7105 98916 tile=((dl/11)&1)+s_tile;
7106 98916 basetile = s_tile;
7107 }
7108 }
7109 157529 break;
7110
7111 case aNEWZORA:
7112 {
7113 428287 f4=(clk/16)%4;
7114
7115 428287 tiledir(dir,true);
7116 int32_t dl;
7117
7118
4/4
✓ Branch 0 taken 304957 times.
✓ Branch 1 taken 123330 times.
✓ Branch 2 taken 159809 times.
✓ Branch 3 taken 145148 times.
428287 if((clk>35)&&(clk<36+67)) //surfaced
7119 {
7120
4/4
✓ Branch 0 taken 123977 times.
✓ Branch 1 taken 21171 times.
✓ Branch 2 taken 17680 times.
✓ Branch 3 taken 106297 times.
145148 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7121 {
7122 106297 tile+=80;
7123 106297 } //mouth closed
7124 else
7125 {
7126 38851 tile+=40;
7127 }
7128
7129 145148 tile+=f4;
7130 145148 }
7131 else
7132 {
7133
2/2
✓ Branch 0 taken 123330 times.
✓ Branch 1 taken 159809 times.
283139 if(clk<36)
7134 {
7135 123330 dl=clk+5;
7136 123330 }
7137 else
7138 {
7139 159809 dl=clk-36-66;
7140 }
7141
7142 283139 tile+=((dl/5)&3);
7143 }
7144 }
7145 428287 break;
7146
7147 case a4FRM4EYE:
7148 case a2FRM4EYE:
7149 case a4FRM8EYE:
7150 case a4FRM8EYEB: //big version
7151 case a4FRM4EYEB:
7152 {
7153 128056 tilerows = 2;
7154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakex = x + 8*(zc_max(1,txsz)-1);
7155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakey = y + 8*(zc_max(1,tysz)-1);
7156 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7157 128056 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7158 128056 int32_t lookat=zc_oldrand()&15;
7159
7160
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 87102 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
128056 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7161 {
7162 20770 lookat=l_down;
7163 20770 }
7164
4/4
✓ Branch 0 taken 41196 times.
✓ Branch 1 taken 66090 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 21012 times.
107286 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7165 {
7166 21012 lookat=down;
7167 21012 }
7168
4/4
✓ Branch 0 taken 33446 times.
✓ Branch 1 taken 52828 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13262 times.
86274 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7169 {
7170 13262 lookat=r_down;
7171 13262 }
7172
4/4
✓ Branch 0 taken 32038 times.
✓ Branch 1 taken 40974 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11854 times.
73012 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7173 {
7174 11854 lookat=right;
7175 11854 }
7176
4/4
✓ Branch 0 taken 25060 times.
✓ Branch 1 taken 36098 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4876 times.
61158 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7177 {
7178 4876 lookat=r_up;
7179 4876 }
7180
4/4
✓ Branch 0 taken 26018 times.
✓ Branch 1 taken 30264 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5834 times.
56282 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7181 {
7182 5834 lookat=up;
7183 5834 }
7184
4/4
✓ Branch 0 taken 30200 times.
✓ Branch 1 taken 20248 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 10016 times.
50448 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7185 {
7186 10016 lookat=l_up;
7187 10016 }
7188 else
7189 {
7190 40432 lookat=left;
7191 }
7192
7193 128056 int32_t dir2 = dir;
7194 128056 dir = lookat;
7195
3/6
✓ Branch 0 taken 128056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128056 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128056 times.
128056 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7196 else
7197 {
7198 tiledir_big(dir,(anim == a4FRM4EYEB));
7199 tile+=2*f4;
7200 ignore_extend = true;
7201 }
7202 128056 dir = dir2;
7203 }
7204 128056 break;
7205
7206 case aFLIP:
7207 {
7208 1050207 flip = f2&1;
7209 }
7210 1050207 break;
7211
7212 case a2FRM:
7213 {
7214 934304 tile += (1-f2);
7215 }
7216 934304 break;
7217
7218 case a2FRMB:
7219 {
7220 tile+= 2*(1-f2);
7221 ignore_extend = true;
7222 }
7223 break;
7224
7225 case a2FRM4DIR:
7226 {
7227 266817 basetile = n_frame_n_dir(2, 4, f2&1);
7228 }
7229 266817 break;
7230
7231 case a4FRM4DIRF:
7232 {
7233 2408805 basetile = n_frame_n_dir(4,4,f4);
7234
7235
2/2
✓ Branch 0 taken 1574669 times.
✓ Branch 1 taken 834136 times.
2408805 if(clk2>0) //stopped to fire
7236 {
7237 834136 tile+=20;
7238
7239
2/2
✓ Branch 0 taken 413682 times.
✓ Branch 1 taken 420454 times.
834136 if(clk2<17) //firing
7240 {
7241 420454 tile+=20;
7242 420454 }
7243 834136 }
7244 }
7245 2408805 break;
7246
7247 case a4FRM4DIR:
7248 {
7249 3857795 basetile = n_frame_n_dir(4,4,f4);
7250 }
7251 3857795 break;
7252
7253 case a4FRM8DIRF:
7254 {
7255 tilerows = 2;
7256 basetile = n_frame_n_dir(4,8,f4);
7257
7258 if(clk2>0) //stopped to fire
7259 {
7260 tile+=40;
7261
7262 if(clk2<17) //firing
7263 {
7264 tile+=40;
7265 }
7266 }
7267 }
7268 break;
7269
7270 case a4FRM8DIRB:
7271 case a4FRM8DIRFB:
7272 {
7273 3868 tilerows = 2;
7274 3868 tiledir_big(dir,false);
7275 3868 tile+=2*f4;
7276
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7277 {
7278 tile+=80;
7279
7280 if(clk2<17) //firing
7281 {
7282 tile+=80;
7283 }
7284 }
7285 3868 ignore_extend = true;
7286 }
7287 3868 break;
7288
7289 case a4FRM4DIRB:
7290 case a4FRM4DIRFB:
7291 {
7292 tilerows = 2;
7293 tiledir_big(dir,true);
7294 tile+=2*f4;
7295 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7296 {
7297 tile+=40;
7298
7299 if(clk2<17) //firing
7300 {
7301 tile+=40;
7302 }
7303 }
7304 ignore_extend = true;
7305 }
7306 break;
7307
7308 case aOCTO:
7309 {
7310
5/5
✓ Branch 0 taken 2913 times.
✓ Branch 1 taken 85458 times.
✓ Branch 2 taken 96229 times.
✓ Branch 3 taken 112826 times.
✓ Branch 4 taken 101887 times.
399313 switch(dir)
7311 {
7312 case up:
7313 85458 flip = 2;
7314 85458 break;
7315
7316 case down:
7317 96229 flip = 0;
7318 96229 break;
7319
7320 case left:
7321 112826 flip = 0;
7322 112826 tile += 2;
7323 112826 break;
7324
7325 case right:
7326 101887 flip = 1;
7327 101887 tile += 2;
7328 101887 break;
7329 }
7330
7331 399313 tile+=f2;
7332 }
7333 399313 break;
7334
7335 case aWALK:
7336 {
7337
5/5
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 207694 times.
✓ Branch 3 taken 256906 times.
✓ Branch 4 taken 256215 times.
912736 switch(dir)
7338 {
7339 case up:
7340 187339 tile+=3;
7341 187339 flip = f2;
7342 187339 break;
7343
7344 case down:
7345 207694 tile+=2;
7346 207694 flip = f2;
7347 207694 break;
7348
7349 case left:
7350 256906 flip=1;
7351 256906 tile += f2;
7352 256906 break;
7353
7354 case right:
7355 256215 flip=0;
7356 256215 tile += f2;
7357 256215 break;
7358 }
7359 }
7360 912736 break;
7361
7362 case aDWALK:
7363 {
7364
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 533443 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
614651 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7365 {
7366 tile=s_tile;
7367 basetile = s_tile;
7368 }
7369
7370
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129268 times.
✓ Branch 2 taken 133261 times.
✓ Branch 3 taken 177242 times.
✓ Branch 4 taken 174880 times.
614651 switch(dir)
7371 {
7372 case up:
7373 129268 tile+=2;
7374 129268 flip=f2;
7375 129268 break;
7376
7377 case down:
7378 133261 flip=0;
7379 133261 tile+=(1-f2);
7380 133261 break;
7381
7382 case left:
7383 177242 flip=1;
7384 177242 tile+=(3+f2);
7385 177242 break;
7386
7387 case right:
7388 174880 flip=0;
7389 174880 tile+=(3+f2);
7390 174880 break;
7391 }
7392 }
7393 614651 break;
7394
7395 case aTEK:
7396 {
7397
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 60556 times.
161932 if(misc==0)
7398 {
7399 60556 tile += f2;
7400 60556 }
7401
2/2
✓ Branch 0 taken 53958 times.
✓ Branch 1 taken 47418 times.
101376 else if(misc!=1)
7402 {
7403 47418 ++tile;
7404 47418 }
7405 }
7406 161932 break;
7407
7408 case aNEWTEK:
7409 {
7410
2/2
✓ Branch 0 taken 329922 times.
✓ Branch 1 taken 987930 times.
1317852 if(step<0) //up
7411 {
7412
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 162358 times.
✓ Branch 2 taken 167564 times.
329922 switch(clk3)
7413 {
7414 case left:
7415 162358 flip=0;
7416 162358 tile+=20;
7417 162358 break;
7418
7419 case right:
7420 167564 flip=0;
7421 167564 tile+=24;
7422 167564 break;
7423 }
7424 329922 }
7425
2/2
✓ Branch 0 taken 42115 times.
✓ Branch 1 taken 945815 times.
987930 else if(step==0)
7426 {
7427
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31831 times.
✓ Branch 2 taken 10284 times.
42115 switch(clk3)
7428 {
7429 case left:
7430 31831 flip=0;
7431 31831 tile+=8;
7432 31831 break;
7433
7434 case right:
7435 10284 flip=0;
7436 10284 tile+=12;
7437 10284 break;
7438 }
7439 42115 } //down
7440 else
7441 {
7442
3/3
✓ Branch 0 taken 64726 times.
✓ Branch 1 taken 445156 times.
✓ Branch 2 taken 435933 times.
945815 switch(clk3)
7443 {
7444 case left:
7445 445156 flip=0;
7446 445156 tile+=28;
7447 445156 break;
7448
7449 case right:
7450 435933 flip=0;
7451 435933 tile+=32;
7452 435933 break;
7453 }
7454 }
7455
7456
2/2
✓ Branch 0 taken 845637 times.
✓ Branch 1 taken 472215 times.
1317852 if(misc==0)
7457 {
7458 472215 tile+=f4;
7459 472215 }
7460
2/2
✓ Branch 0 taken 408849 times.
✓ Branch 1 taken 436788 times.
845637 else if(misc!=1)
7461 {
7462 436788 tile+=2;
7463 436788 }
7464 }
7465 1317852 break;
7466
7467 case aARMOS:
7468 {
7469
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
7470 {
7471 3306 tile += fx;
7472
7473
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
7474 847 tile += 2;
7475 3306 }
7476 }
7477 5459 break;
7478
7479 case aARMOS4:
7480 {
7481
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6170 times.
✓ Branch 2 taken 12989 times.
✓ Branch 3 taken 9114 times.
✓ Branch 4 taken 8963 times.
37236 switch(dir)
7482 {
7483 case up:
7484 6170 flip=0;
7485 6170 break;
7486
7487 case down:
7488 12989 flip=0;
7489 12989 tile+=4;
7490 12989 break;
7491
7492 case left:
7493 9114 flip=0;
7494 9114 tile+=8;
7495 9114 break;
7496
7497 case right:
7498 8963 flip=0;
7499 8963 tile+=12;
7500 8963 break;
7501 }
7502
7503
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 30124 times.
37236 if(!fading)
7504 {
7505 30124 tile+=f4;
7506 30124 }
7507 }
7508 37236 break;
7509
7510 case aGHINI:
7511 {
7512
4/4
✓ Branch 0 taken 14931 times.
✓ Branch 1 taken 18961 times.
✓ Branch 2 taken 40404 times.
✓ Branch 3 taken 374 times.
74670 switch(dir)
7513 {
7514 case 8:
7515 case 9:
7516 case up:
7517 14931 ++tile;
7518 14931 flip=0;
7519 14931 break;
7520
7521 case 15:
7522 374 ++tile;
7523 374 flip=1;
7524 374 break;
7525
7526 case 10:
7527 case 11:
7528 case right:
7529 18961 flip=1;
7530 18961 break;
7531
7532 default:
7533 40404 flip=0;
7534 40404 break;
7535 }
7536 }
7537 74670 break;
7538
7539 case a2FRMPOS:
7540 {
7541 1313148 tile+=posframe;
7542 }
7543 1313148 break;
7544
7545 case a4FRMPOS4DIR:
7546 {
7547 216057 basetile = n_frame_n_dir(4,4,0);
7548 // tile+=f2;
7549 216057 tile+=posframe;
7550 }
7551 216057 break;
7552
7553 case a4FRMPOS4DIRF:
7554 {
7555 basetile = n_frame_n_dir(4,4,0);
7556
7557 if(clk2>0) //stopped to fire
7558 {
7559 tile+=20;
7560
7561 if(clk2<17) //firing
7562 {
7563 tile+=20;
7564 }
7565 }
7566
7567 // tile+=f2;
7568 tile+=posframe;
7569 }
7570 break;
7571
7572 case a4FRMPOS8DIR:
7573 {
7574 3483844 tilerows = 2;
7575 3483844 int32_t n = tile;
7576 3483844 basetile = n_frame_n_dir(4,8,0);
7577 // tile+=f2;
7578 3483844 tile+=posframe;
7579 }
7580 3483844 break;
7581
7582 case a4FRMPOS8DIRF:
7583 {
7584 tilerows = 2;
7585 basetile = n_frame_n_dir(4,8,0);
7586
7587 if(clk2>0) //stopped to fire
7588 {
7589 tile+=40;
7590
7591 if(clk2<17) //firing
7592 {
7593 tile+=40;
7594 }
7595 }
7596
7597 tile+=posframe;
7598 }
7599 break;
7600
7601 case aNEWLEV:
7602 {
7603 281552 tiledir(dir,true);
7604
7605
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
7606 {
7607 case -1:
7608 case 0:
7609 92775 return;
7610
7611 case 1:
7612
7613 // case 5: cs = d->misc2; break;
7614 case 5:
7615 45501 cs = dmisc2;
7616 45501 break;
7617
7618 case 2:
7619 case 4:
7620 18315 tile += 20;
7621 18315 break;
7622
7623 case 3:
7624 124961 tile += 40;
7625 124961 break;
7626 }
7627
7628 188777 tile+=f4;
7629 }
7630 188777 break;
7631
7632 case aLEV:
7633 {
7634 219227 f4 = ((clk/5)&1);
7635
7636
4/5
✓ Branch 0 taken 106859 times.
✓ Branch 1 taken 24845 times.
✓ Branch 2 taken 11238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76285 times.
219227 switch(misc)
7637 {
7638 case -1:
7639 case 0:
7640 106859 return;
7641
7642 case 1:
7643
7644 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7645 case 5:
7646 24845 tile += (f2) ? 1 : 0;
7647 24845 cs = dmisc2;
7648 24845 break;
7649
7650 case 2:
7651 case 4:
7652 11238 tile += 2;
7653 11238 break;
7654
7655 case 3:
7656 76285 tile += (f4) ? 4 : 3;
7657 76285 break;
7658 }
7659 }
7660 112368 break;
7661
7662 case aWALLM:
7663 {
7664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89141 times.
89141 if(!dummy_bool[1])
7665 {
7666 89141 tile += f2;
7667 89141 }
7668 }
7669 89141 break;
7670
7671 case aNEWWALLM:
7672 {
7673 233641 int32_t tempdir=0;
7674
7675
4/4
✓ Branch 0 taken 30389 times.
✓ Branch 1 taken 24290 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 172241 times.
233641 switch(misc)
7676 {
7677 case 1:
7678 case 2:
7679 24290 tempdir=clk3;
7680 24290 break;
7681
7682 case 3:
7683 case 4:
7684 case 5:
7685 30389 tempdir=dir;
7686 30389 break;
7687
7688 case 6:
7689 case 7:
7690 6721 tempdir=clk3^1;
7691 6721 break;
7692 }
7693
7694 233641 tiledir(tempdir,true);
7695
7696
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 233063 times.
233641 if(!dummy_bool[1])
7697 {
7698 233063 tile+=f4;
7699 233063 }
7700 }
7701 233641 break;
7702
7703 case a4FRMNODIR:
7704 {
7705 38974 tile+=f4;
7706 }
7707 38974 break;
7708
7709 } // switch(d->anim)
7710
7711 // flashing
7712 // if(d->flags2 & guy_flashing)
7713
2/2
✓ Branch 0 taken 22179460 times.
✓ Branch 1 taken 524534 times.
22703994 if(flags2 & guy_flashing)
7714 {
7715 524534 cs = (frame&3) + 6;
7716 524534 }
7717
7718
2/2
✓ Branch 0 taken 22671880 times.
✓ Branch 1 taken 32114 times.
22703994 if(flags2&guy_transparent)
7719 {
7720 32114 drawstyle=1;
7721 32114 }
7722
7723 22703994 int32_t change = tile-basetile;
7724
7725
3/6
✓ Branch 0 taken 1173004 times.
✓ Branch 1 taken 21530990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1173004 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22703994 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7726 {
7727
2/2
✓ Branch 0 taken 953662 times.
✓ Branch 1 taken 219342 times.
1173004 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7728 {
7729 953662 tile=basetile+txsz*change;
7730 953662 }
7731 else
7732 {
7733 219342 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7734 }
7735 1173004 }
7736 else
7737 {
7738 21530990 tile=basetile+change;
7739 }
7740 22903770 }
7741
7742 53882 int32_t wpnsfx(int32_t wpn)
7743 {
7744
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17500 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 18023 times.
✓ Branch 4 taken 11644 times.
✓ Branch 5 taken 6432 times.
53882 switch(wpn)
7745 {
7746 case ewFireTrail:
7747 case ewFlame:
7748 case ewFlame2Trail:
7749 case ewFlame2:
7750 17500 return WAV_FIRE;
7751
7752 case ewWind:
7753 case ewMagic:
7754 283 return WAV_WAND;
7755
7756 case ewIce:
7757 return WAV_ZN1ICE;
7758
7759 case ewRock:
7760
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 6168 times.
6432 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7761 6168 break;
7762
7763 case ewFireball2:
7764 case ewFireball:
7765
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 18016 times.
18023 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7766 18016 }
7767
7768 35828 return -1;
7769 53882 }
7770
7771 42797394 int32_t enemy::run_script(int32_t mode)
7772 {
7773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42797394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42797394 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7774
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42797394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42797394 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7775 42797394 return RUNSCRIPT_OK;
7776 int32_t ret = RUNSCRIPT_OK;
7777 alloc_scriptmem();
7778 switch(mode)
7779 {
7780 case MODE_NORMAL:
7781 return ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7782 case MODE_WAITDRAW:
7783 if(waitdraw)
7784 {
7785 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7786 waitdraw = 0;
7787 }
7788 break;
7789 }
7790 return ret;
7791 42797394 }
7792 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7793 {
7794 return al_map_rgba(255,0,0,opacity);
7795 }
7796 /********************************/
7797 /********* Guy Class **********/
7798 /********************************/
7799
7800 // good guys, fires, fairy, and other non-enemies
7801 // based on enemy class b/c guys in dungeons act sort of like enemies
7802 // also easier to manage all the guys this way
7803 2880 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7804 2880 {
7805 1440 mainguy=mg;
7806 1440 canfreeze=false;
7807 1440 dir=down;
7808
3/6
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
1440 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7809 1440 hxofs=2;
7810 1440 hzsz=8;
7811 1440 hit_width=12;
7812 1440 hit_height=17;
7813
7814
10/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 980 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 205 times.
✓ Branch 9 taken 245 times.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 191 times.
1440 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7815 {
7816 1249 superman = 1;
7817 1249 hxofs=1000;
7818 1249 }
7819 1440 }
7820
7821 563152 bool guy::animate(int32_t index)
7822 {
7823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563152 times.
563152 if(switch_hooked) return enemy::animate(index);
7824
6/6
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 269104 times.
✓ Branch 4 taken 1406 times.
✓ Branch 5 taken 717 times.
563152 if(mainguy && clk==0 && misc==0)
7825 {
7826 717 setupscreen();
7827 717 misc = 1;
7828 717 }
7829
7830
4/4
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 271014 times.
✓ Branch 3 taken 213 times.
563152 if(mainguy && fadeclk==0)
7831 213 return true;
7832
7833 562939 hp=256; // good guys never die...
7834
7835
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 562644 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 9 times.
562939 if(hclk && !clk2)
7836 {
7837 // but if they get hit...
7838 9 ++clk2; // only do this once
7839
7840
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(!get_qr(qr_NOGUYFIRES))
7841 {
7842 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7843 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7844 1 }
7845 9 }
7846
7847 562939 return enemy::animate(index);
7848 563152 }
7849
7850 566391 void guy::draw(BITMAP *dest)
7851 {
7852 566391 update_enemy_frame();
7853
7854
6/6
✓ Branch 0 taken 274338 times.
✓ Branch 1 taken 292053 times.
✓ Branch 2 taken 14309 times.
✓ Branch 3 taken 260029 times.
✓ Branch 4 taken 7153 times.
✓ Branch 5 taken 7156 times.
566391 if(!mainguy || fadeclk<0 || fadeclk&1)
7855 559235 enemy::draw(dest);
7856 566391 }
7857
7858 /*******************************/
7859 /********* Enemies *********/
7860 /*******************************/
7861
7862 748 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7863 748 {
7864 374 clk4=0;
7865 374 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7866 // Spawn type
7867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if(flags & guy_fadeflicker)
7868 {
7869 clk=0;
7870 superman = 1;
7871 fading=fade_flicker;
7872 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7873 dir=down;
7874
7875 if(!canmove(down,(zfix)8,spw_none,false))
7876 clk3=int32_t(13.0/step);
7877 }
7878
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 else if(flags & guy_fadeinstant)
7879 {
7880 clk=0;
7881 }
7882 374 SIZEflags = d->SIZEflags;
7883
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7884 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7885 // al_trace("Enemy txsz:%i\n", txsz);
7886
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7888
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7889
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7890
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7891
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7892 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7895 {
7896 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
7897 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
7898 }
7899
7900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
7901 374 }
7902
7903 78853 bool eFire::animate(int32_t index)
7904 {
7905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78853 times.
78853 if(switch_hooked) return enemy::animate(index);
7906
2/4
✓ Branch 0 taken 78853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78853 times.
78853 if(fallclk||drownclk) return enemy::animate(index);
7907
2/2
✓ Branch 0 taken 78278 times.
✓ Branch 1 taken 575 times.
78853 if(fading)
7908 {
7909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(++clk4 > 60)
7910 {
7911 clk4=0;
7912 superman=0;
7913 fading=0;
7914
7915 if(flags2&cmbflag_armos && z==0 && fakez==0)
7916 removearmos(x,y,ffcactivated);
7917
7918 clk2=0;
7919
7920 if(!canmove(down,(zfix)8,spw_none,false))
7921 {
7922 dir=0;
7923 y = y.getInt() & 0xF0;
7924 }
7925
7926 return Dead(index);
7927 }
7928
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
575 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
7929 removearmos(x,y,ffcactivated);
7930 575 }
7931
7932 78853 return enemy::animate(index);
7933 78853 }
7934
7935 166722 void eFire::draw(BITMAP *dest)
7936 {
7937 166722 update_enemy_frame();
7938 166722 enemy::draw(dest);
7939 166722 }
7940
7941 149 int32_t eFire::takehit(weapon *w, weapon* realweap)
7942 {
7943 149 int32_t wpnId = w->id;
7944 149 int32_t wpnDir = w->dir;
7945
7946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7947 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
7948 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
7949 {
7950 shield = false;
7951 flags &= ~(inv_left|inv_right|inv_back|inv_front);
7952
7953 if(get_qr(qr_BRKNSHLDTILES))
7954 o_tile=s_tile;
7955 }
7956
7957 149 int32_t ret = enemy::takehit(w,realweap);
7958 149 return ret;
7959 }
7960
7961 void eFire::break_shield()
7962 {
7963 if(!shield)
7964 return;
7965
7966 flags&=~(inv_front | inv_back | inv_left | inv_right);
7967 shield=false;
7968
7969 if(get_qr(qr_BRKNSHLDTILES))
7970 o_tile=s_tile;
7971 }
7972
7973 9800 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7974 9800 {
7975 //zprint2("npct other::other\n");
7976 4900 clk4=0;
7977 4900 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7978
7979 // Spawn type
7980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if(flags & guy_fadeflicker)
7981 {
7982 clk=0;
7983 superman = 1;
7984 fading=fade_flicker;
7985 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7986 dir=down;
7987
7988 if(!canmove(down,(zfix)8,spw_none,false))
7989 clk3=int32_t(13.0/step);
7990 }
7991
2/2
✓ Branch 0 taken 4729 times.
✓ Branch 1 taken 171 times.
4900 else if(flags & guy_fadeinstant)
7992 {
7993 171 clk=0;
7994 171 }
7995 4900 SIZEflags = d->SIZEflags;
7996
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7997 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7998 // al_trace("Enemy txsz:%i\n", txsz);
7999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8003
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8004
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8005 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8008 {
8009 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8010 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8011 }
8012
8013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8014 4900 }
8015
8016 917976 bool eOther::animate(int32_t index)
8017 {
8018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 917976 times.
917976 if(switch_hooked) return enemy::animate(index);
8019
2/4
✓ Branch 0 taken 917976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 917976 times.
917976 if(fallclk||drownclk) return enemy::animate(index);
8020 //zprint2("npct other::animate\n");
8021
2/2
✓ Branch 0 taken 916640 times.
✓ Branch 1 taken 1336 times.
917976 if(fading)
8022 {
8023
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1335 times.
1336 if(++clk4 > 60)
8024 {
8025 1 clk4=0;
8026 1 superman=0;
8027 1 fading=0;
8028
8029
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&cmbflag_armos && z==0 && fakez==0)
8030 removearmos(x,y,ffcactivated);
8031
8032 1 clk2=0;
8033
8034
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!canmove(down,(zfix)8,spw_none,false))
8035 {
8036 dir=0;
8037 y = y.getInt() & 0xF0;
8038 }
8039
8040 1 return Dead(index);
8041 }
8042
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1335 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8043 removearmos(x,y,ffcactivated);
8044 1335 }
8045
8046 917975 return enemy::animate(index);
8047 917976 }
8048
8049 944738 void eOther::draw(BITMAP *dest)
8050 {
8051 944738 update_enemy_frame();
8052 944738 enemy::draw(dest);
8053 944738 }
8054
8055 5691 int32_t eOther::takehit(weapon *w, weapon* realweap)
8056 {
8057 5691 int32_t wpnId = w->id;
8058 5691 int32_t wpnDir = w->dir;
8059
8060
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
5691 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8061 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8062 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8063 {
8064 shield = false;
8065 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8066
8067 if(get_qr(qr_BRKNSHLDTILES))
8068 o_tile=s_tile;
8069 }
8070
8071 5691 int32_t ret = enemy::takehit(w,realweap);
8072 5691 return ret;
8073 }
8074
8075 void eOther::break_shield()
8076 {
8077 if(!shield)
8078 return;
8079
8080 flags&=~(inv_front | inv_back | inv_left | inv_right);
8081 shield=false;
8082
8083 if(get_qr(qr_BRKNSHLDTILES))
8084 o_tile=s_tile;
8085 }
8086
8087
8088 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8089 {
8090 clk4=0;
8091 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8092
8093 // Spawn type
8094 if(flags & guy_fadeflicker)
8095 {
8096 clk=0;
8097 superman = 1;
8098 fading=fade_flicker;
8099 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8100 dir=down;
8101
8102 if(!canmove(down,(zfix)8,spw_none,false))
8103 clk3=int32_t(13.0/step);
8104 }
8105 else if(flags & guy_fadeinstant)
8106 {
8107 clk=0;
8108 }
8109 SIZEflags = d->SIZEflags;
8110 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8111 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8112 // al_trace("Enemy txsz:%i\n", txsz);
8113 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8114 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8115 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8116 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8117 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8118 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8119 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8120 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8121 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8122 {
8123 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8124 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8125 }
8126
8127 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8128 }
8129
8130 bool eScript::animate(int32_t index)
8131 {
8132 if(switch_hooked) return enemy::animate(index);
8133 if(fallclk||drownclk) return enemy::animate(index);
8134 if(fading)
8135 {
8136 if(++clk4 > 60)
8137 {
8138 clk4=0;
8139 superman=0;
8140 fading=0;
8141
8142 if(flags2&cmbflag_armos && z==0 && fakez==0)
8143 removearmos(x,y,ffcactivated);
8144
8145 clk2=0;
8146
8147 if(!canmove(down,(zfix)8,spw_none,false))
8148 {
8149 dir=0;
8150 y = y.getInt() & 0xF0;
8151 }
8152
8153 return Dead(index);
8154 }
8155 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8156 removearmos(x,y,ffcactivated);
8157 }
8158
8159 return enemy::animate(index);
8160 }
8161
8162 void eScript::draw(BITMAP *dest)
8163 {
8164 update_enemy_frame();
8165 enemy::draw(dest);
8166 }
8167
8168 int32_t eScript::takehit(weapon *w, weapon* realweap)
8169 {
8170 int32_t wpnId = w->id;
8171 int32_t wpnDir = w->dir;
8172
8173 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8174 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8175 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8176 {
8177 shield = false;
8178 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8179
8180 if(get_qr(qr_BRKNSHLDTILES))
8181 o_tile=s_tile;
8182 }
8183
8184 int32_t ret = enemy::takehit(w,realweap);
8185 return ret;
8186 }
8187
8188 void eScript::break_shield()
8189 {
8190 if(!shield)
8191 return;
8192
8193 flags&=~(inv_front | inv_back | inv_left | inv_right);
8194 shield=false;
8195
8196 if(get_qr(qr_BRKNSHLDTILES))
8197 o_tile=s_tile;
8198 }
8199
8200
8201 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8202 {
8203 clk4=0;
8204 hyofs = -32768; //No hitbox initially.
8205 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8206
8207 // Spawn type
8208 if(flags & guy_fadeflicker)
8209 {
8210 clk=0;
8211 superman = 1;
8212 fading=fade_flicker;
8213 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8214 dir=down;
8215
8216 if(!canmove(down,(zfix)8,spw_none,false))
8217 clk3=int32_t(13.0/step);
8218 }
8219 else if(flags & guy_fadeinstant)
8220 {
8221 clk=0;
8222 }
8223 SIZEflags = d->SIZEflags;
8224 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8225 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8226 // al_trace("Enemy txsz:%i\n", txsz);
8227 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8228 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8229 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8230 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8231 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8232 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8233 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8234 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8235 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8236 {
8237 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8238 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8239 }
8240
8241 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8242 }
8243
8244 bool eFriendly::animate(int32_t index)
8245 {
8246 if(switch_hooked) return enemy::animate(index);
8247 if(fallclk||drownclk) return enemy::animate(index);
8248 if(fading)
8249 {
8250 if(++clk4 > 60)
8251 {
8252 clk4=0;
8253 superman=0;
8254 fading=0;
8255
8256 if(flags2&cmbflag_armos && z==0 && fakez==0)
8257 removearmos(x,y,ffcactivated);
8258
8259 clk2=0;
8260
8261 if(!canmove(down,(zfix)8,spw_none,false))
8262 {
8263 dir=0;
8264 y = y.getInt() & 0xF0;
8265 }
8266
8267 return Dead(index);
8268 }
8269 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8270 removearmos(x,y,ffcactivated);
8271 }
8272
8273 return enemy::animate(index);
8274 }
8275
8276 void eFriendly::draw(BITMAP *dest)
8277 {
8278 update_enemy_frame();
8279 enemy::draw(dest);
8280 }
8281
8282 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8283 {
8284 int32_t wpnId = w->id;
8285 int32_t wpnDir = w->dir;
8286
8287 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8288 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8289 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8290 {
8291 shield = false;
8292 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8293
8294 if(get_qr(qr_BRKNSHLDTILES))
8295 o_tile=s_tile;
8296 }
8297
8298 int32_t ret = enemy::takehit(w,realweap);
8299 return ret;
8300 }
8301
8302 void eFriendly::break_shield()
8303 {
8304 if(!shield)
8305 return;
8306
8307 flags&=~(inv_front | inv_back | inv_left | inv_right);
8308 shield=false;
8309
8310 if(get_qr(qr_BRKNSHLDTILES))
8311 o_tile=s_tile;
8312 }
8313
8314
8315 354053 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8316 {
8317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354053 times.
354053 if (ffcactive)
8318 {
8319 removearmosffc(ffcactive-1);
8320 return;
8321 }
8322
2/2
✓ Branch 0 taken 353387 times.
✓ Branch 1 taken 666 times.
354053 if(did_armos)
8323 {
8324 353387 return;
8325 }
8326
8327 666 did_armos=true;
8328 666 ax&=0xF0;
8329 666 ay&=0xF0;
8330 666 int32_t cd = (ax>>4)+ay;
8331 666 int32_t f = MAPFLAG(ax,ay);
8332 666 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8333
8334
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 121 times.
666 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8335 {
8336 545 return;
8337 }
8338
8339 121 tmpscr->data[cd] = tmpscr->undercombo;
8340 121 tmpscr->cset[cd] = tmpscr->undercset;
8341 121 tmpscr->sflag[cd] = 0;
8342
8343
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
121 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8344 {
8345 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8346 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8347 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8348 20 sfx(tmpscr->secretsfx);
8349 20 }
8350
8351
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
121 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8352 {
8353
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8354 {
8355 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8356 2 sfx(tmpscr->secretsfx);
8357 2 }
8358 2 }
8359
8360 121 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8361 354053 }
8362
8363 void enemy::removearmosffc(int32_t pos)
8364 {
8365 if(did_armos)
8366 {
8367 return;
8368 }
8369
8370 did_armos=true;
8371 ffcdata& ffc = tmpscr->ffcs[pos];
8372 newcombo const& cmb = combobuf[ffc.getData()];
8373 int32_t f2 = cmb.flag;
8374
8375 if(cmb.type!=cARMOS)
8376 {
8377 return;
8378 }
8379
8380 ffc.setData(tmpscr->undercombo);
8381 ffc.cset = tmpscr->undercset;
8382
8383 if(f2 == mfARMOS_SECRET)
8384 {
8385 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
8386 ffc.cset = tmpscr->secretcset[sSTAIRS];
8387 sfx(tmpscr->secretsfx);
8388 }
8389
8390 if(f2 == mfARMOS_ITEM)
8391 {
8392 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8393 {
8394 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8395 sfx(tmpscr->secretsfx);
8396 }
8397 }
8398
8399 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
8400 }
8401
8402
8403 280 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8404 280 {
8405 140 fading=fade_flicker;
8406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8407 140 dir=12;
8408 140 movestatus=1;
8409
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=0;
8410 140 clk=0;
8411 140 clk4=0;
8412 140 SIZEflags = d->SIZEflags;
8413
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8414 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8415 // al_trace("Enemy txsz:%i\n", txsz);
8416
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8419
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8420
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8421
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8422 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8425 {
8426 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8427 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8428 }
8429
8430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8431 140 }
8432
8433 51269 bool eGhini::animate(int32_t index)
8434 {
8435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51269 times.
51269 if(switch_hooked) return enemy::animate(index);
8436
2/4
✓ Branch 0 taken 51269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51269 times.
51269 if(fallclk||drownclk) return enemy::animate(index);
8437
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 51233 times.
51269 if(dying)
8438 36 return Dead(index);
8439
8440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51233 times.
51233 if(dmisc1)
8441 {
8442
2/2
✓ Branch 0 taken 42826 times.
✓ Branch 1 taken 8407 times.
51233 if(misc)
8443 {
8444
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 if(clk4>160)
8445 31041 misc=2;
8446
8447
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8448 42826 removearmos(x,y,ffcactivated);
8449 42826 }
8450
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 135 times.
8407 else if(clk4>=60)
8451 {
8452 135 misc=1;
8453 135 clk3=32;
8454 135 fading=0;
8455
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if (ffcactivated > 0)
8456 {
8457 guygridffc[ffcactivated-1] = 0;
8458 removearmosffc(ffcactivated-1);
8459 }
8460 else
8461 {
8462 135 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8463 135 removearmos(x,y);
8464 }
8465 135 }
8466 51233 }
8467
8468 51233 clk4++;
8469
8470 51233 return enemy::animate(index);
8471 51269 }
8472
8473 102598 void eGhini::draw(BITMAP *dest)
8474 {
8475 102598 update_enemy_frame();
8476 102598 enemy::draw(dest);
8477 102598 }
8478
8479 2 void eGhini::kickbucket()
8480 {
8481 2 hp=-1000; // don't call death_sfx()
8482 2 }
8483
8484
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
8823 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8485 5882 {
8486
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 old_y=y;
8487 2941 dir=down;
8488 2941 misc=1;
8489 2941 clk=-15;
8490
8491
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 573 times.
2941 if(!BSZ)
8492
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 clk*=zc_oldrand()%3+1;
8493
8494 // avoid divide by 0 errors
8495
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc1 == 0)
8496 dmisc1 = 24;
8497
8498
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc2 == 0)
8499 dmisc2 = 3;
8500
8501 //nets+760;
8502 2941 SIZEflags = d->SIZEflags;
8503
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8504 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8505 // al_trace("Enemy txsz:%i\n", txsz);
8506
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8508
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8510
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8511
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8512 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8515 {
8516 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8517 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8518 }
8519
8520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8521 2941 }
8522
8523 908367 bool eTektite::animate(int32_t index)
8524 {
8525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 908367 times.
908367 if(switch_hooked) return enemy::animate(index);
8526
4/4
✓ Branch 0 taken 903407 times.
✓ Branch 1 taken 4960 times.
✓ Branch 2 taken 4960 times.
✓ Branch 3 taken 906755 times.
908367 if(fallclk||drownclk) return enemy::animate(index);
8527
2/2
✓ Branch 0 taken 19019 times.
✓ Branch 1 taken 887736 times.
906755 if(dying)
8528 19019 return Dead(index);
8529
8530
2/2
✓ Branch 0 taken 865037 times.
✓ Branch 1 taken 22699 times.
887736 if(clk==0)
8531 {
8532 22699 removearmos(x,y,ffcactivated);
8533 22699 }
8534
8535
2/2
✓ Branch 0 taken 554602 times.
✓ Branch 1 taken 333134 times.
887736 if(get_qr(qr_ENEMIESZAXIS))
8536 {
8537 333134 y=floor_y;
8538 333134 }
8539
8540
9/10
✓ Branch 0 taken 805094 times.
✓ Branch 1 taken 82642 times.
✓ Branch 2 taken 798089 times.
✓ Branch 3 taken 7005 times.
✓ Branch 4 taken 798089 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 786913 times.
✓ Branch 8 taken 6942 times.
✓ Branch 9 taken 11586 times.
887736 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8541 {
8542
4/4
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 310803 times.
✓ Branch 2 taken 206484 times.
✓ Branch 3 taken 271244 times.
798499 switch(misc)
8543 {
8544 case 0: // normal
8545
2/2
✓ Branch 0 taken 304080 times.
✓ Branch 1 taken 6723 times.
310803 if(!(zc_oldrand()%dmisc1))
8546 {
8547 6723 misc=1;
8548 6723 clk2=32;
8549 6723 }
8550
8551 310803 break;
8552
8553 case 1: // waiting to pounce
8554
2/2
✓ Branch 0 taken 195359 times.
✓ Branch 1 taken 11125 times.
206484 if(--clk2<=0)
8555 {
8556 11125 int32_t r=zc_oldrand();
8557 11125 misc=2;
8558 11125 step=0-(zslongToFix(dstep*100)); // initial speed
8559 11125 clk3=(r&1)+2; // left or right
8560 11125 clk2start=clk2=(r&31)+10; // flight time
8561
8562
2/2
✓ Branch 0 taken 9762 times.
✓ Branch 1 taken 1363 times.
11125 if(y<32) clk2+=2; // make them come down from top of screen
8563
8564
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 2466 times.
11125 if(y>112) clk2-=2; // make them go back up
8565
8566 11125 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8567 11125 }
8568
8569 206484 break;
8570
8571 case 2: // in flight
8572 271244 move(step);
8573
8574
2/2
✓ Branch 0 taken 130352 times.
✓ Branch 1 taken 140892 times.
271244 if(step>0) //going down
8575 {
8576
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 130196 times.
130352 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8577 {
8578 156 step=0-step;
8579 156 }
8580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8581 {
8582 step=0-step;
8583 }
8584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(ispitfall(x+8,y+16))
8585 {
8586 step=0-step;
8587 }
8588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8589 {
8590 step=0-step;
8591 }
8592
1/2
✓ Branch 0 taken 130196 times.
✗ Branch 1 not taken.
130196 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8593 {
8594 step=0-step;
8595 }
8596 130352 }
8597
2/2
✓ Branch 0 taken 9095 times.
✓ Branch 1 taken 131797 times.
140892 else if(step<0)
8598 {
8599
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 131578 times.
131797 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8600 {
8601 219 step=0-step;
8602 219 }
8603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8604 {
8605 step=0-step;
8606 }
8607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(ispitfall(x+8,y))
8608 {
8609 step=0-step;
8610 }
8611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8612 {
8613 step=0-step;
8614 }
8615
1/2
✓ Branch 0 taken 131578 times.
✗ Branch 1 not taken.
131578 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8616 {
8617 step=0-step;
8618 }
8619 131797 }
8620
8621
2/2
✓ Branch 0 taken 134483 times.
✓ Branch 1 taken 136761 times.
271244 if(clk3==left)
8622 {
8623
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 134382 times.
134483 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8624 {
8625 101 clk3^=1;
8626 101 }
8627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8628 {
8629 clk3^=1;
8630 }
8631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(ispitfall(x,y+8))
8632 {
8633 clk3^=1;
8634 }
8635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8636 {
8637 clk3^=1;
8638 }
8639
1/2
✓ Branch 0 taken 134382 times.
✗ Branch 1 not taken.
134382 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8640 {
8641 clk3^=1;
8642 }
8643 134483 }
8644 else
8645 {
8646
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 136670 times.
136761 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8647 {
8648 91 clk3^=1;
8649 91 }
8650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8651 {
8652 clk3^=1;
8653 }
8654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(ispitfall(x+16,y+8))
8655 {
8656 clk3^=1;
8657 }
8658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8659 {
8660 clk3^=1;
8661 }
8662
1/2
✓ Branch 0 taken 136670 times.
✗ Branch 1 not taken.
136670 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8663 {
8664 clk3^=1;
8665 }
8666 }
8667
8668 271244 --c;
8669
8670
4/4
✓ Branch 0 taken 81892 times.
✓ Branch 1 taken 189352 times.
✓ Branch 2 taken 178175 times.
✓ Branch 3 taken 93069 times.
271244 if(c<0 && step<zslongToFix(dstep*100))
8671 {
8672 93069 step+=zslongToFix(dmisc3*100);
8673 93069 }
8674
8675 271244 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8676
8677
2/2
✓ Branch 0 taken 270922 times.
✓ Branch 1 taken 322 times.
271244 if(x<=16-nb) clk3=right;
8678
8679
2/2
✓ Branch 0 taken 270702 times.
✓ Branch 1 taken 542 times.
271244 if(x>=224+nb) clk3=left;
8680
8681 271244 x += (clk3==left) ? -1 : 1;
8682
8683
4/4
✓ Branch 0 taken 15373 times.
✓ Branch 1 taken 255871 times.
✓ Branch 2 taken 4984 times.
✓ Branch 3 taken 250887 times.
271244 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8684 {
8685
4/4
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 9728 times.
✓ Branch 2 taken 484 times.
✓ Branch 3 taken 177 times.
20357 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8686 {
8687 177 step=0-step;
8688 177 y--;
8689 177 }
8690
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 7892 times.
10212 else if(zc_oldrand()%dmisc2) //land and wait
8691 {
8692 7892 clk=misc=0;
8693 7892 } //land and jump again
8694 else
8695 {
8696 2320 misc=1;
8697 2320 clk2=0;
8698 }
8699 10389 }
8700
8701 261276 break;
8702 } // switch
8703 788531 }
8704
8705
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 551254 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
885120 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8706 {
8707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
8708 {
8709 int32_t tempy = floor_y;
8710 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8711 floor_y = y;
8712 y=tempy-fakez;
8713 old_y = y;
8714 }
8715 else
8716 {
8717 106683 int32_t tempy = floor_y;
8718
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 2353 times.
✓ Branch 3 taken 104330 times.
✓ Branch 4 taken 52359 times.
✓ Branch 5 taken 51971 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8719 106683 floor_y = y;
8720 106683 y=tempy-z;
8721 106683 old_y = y;
8722 }
8723 106683 }
8724
8725
4/4
✓ Branch 0 taken 7005 times.
✓ Branch 1 taken 877383 times.
✓ Branch 2 taken 1407 times.
✓ Branch 3 taken 5598 times.
884388 if(stunclk && (clk&31)==1)
8726 5598 clk=0;
8727
8728 884388 return enemy::animate(index);
8729 903407 }
8730
8731 330586 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8732 {
8733
5/6
✓ Branch 0 taken 161030 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 161030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136696 times.
✓ Branch 5 taken 24334 times.
330586 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8734 24334 return;
8735
8736 306252 int32_t tempy=yofs;
8737 306252 int32_t fdiv = frate/4;
8738
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8739
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8740 306252 efrate:((clk>=(frate>>1))?1:0);
8741 306252 flip = 0;
8742 306252 shadowtile = wpnsbuf[spr_shadow].tile;
8743
8744
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 if(get_qr(qr_NEWENEMYTILES))
8745 {
8746
2/2
✓ Branch 0 taken 200675 times.
✓ Branch 1 taken 105577 times.
306252 if(misc==0)
8747 {
8748 105577 shadowtile+=f2;
8749 105577 }
8750
2/2
✓ Branch 0 taken 91502 times.
✓ Branch 1 taken 109173 times.
200675 else if(misc!=1)
8751 109173 shadowtile+=2;
8752 306252 }
8753 else
8754 {
8755 if(misc==0)
8756 {
8757 shadowtile += f2 ? 1 : 0;
8758 }
8759 else if(misc!=1)
8760 {
8761 ++shadowtile;
8762 }
8763 }
8764
8765 306252 yofs+=8;
8766
8767
4/4
✓ Branch 0 taken 136696 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 84452 times.
✓ Branch 3 taken 52244 times.
306252 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8768 {
8769
6/6
✓ Branch 0 taken 26557 times.
✓ Branch 1 taken 25687 times.
✓ Branch 2 taken 1568 times.
✓ Branch 3 taken 50676 times.
✓ Branch 4 taken 26073 times.
✓ Branch 5 taken 24603 times.
52244 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8770 52244 }
8771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306252 times.
306252 if(!shadow_overpit(this))
8772 306252 enemy::drawshadow(dest,translucent);
8773 306252 yofs=tempy;
8774 330586 }
8775
8776 1500560 void eTektite::draw(BITMAP *dest)
8777 {
8778 1500560 update_enemy_frame();
8779 1500560 enemy::draw(dest);
8780 1500560 }
8781
8782 826 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8783 826 {
8784
2/4
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
413 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8785 413 superman=1;
8786 413 dir=8;
8787 413 hxofs=1000;
8788 413 mainguy=false;
8789 413 count_enemy=false;
8790
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8791 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8792 // al_trace("Enemy txsz:%i\n", txsz);
8793
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
8794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
8795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
8796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
8797
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
8798
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
8799 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8800
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
8801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8802 {
8803 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
8804 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8805 }
8806
8807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
8808 413 }
8809
8810 228794 bool eItemFairy::animate(int32_t index)
8811 {
8812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(switch_hooked) return enemy::animate(index);
8813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(dying)
8814 return Dead(index);
8815
8816 //if(clk>32)
8817 228794 misc=1;
8818 228794 bool w=watch;
8819 228794 watch=false;
8820 228794 variable_walk_8(misc?3:0,0,8,spw_floater);
8821 228794 watch=w;
8822
8823
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 227687 times.
228794 if(clk==0)
8824 {
8825 1107 removearmos(x,y,ffcactivated);
8826 1107 }
8827
8828 228794 return enemy::animate(index);
8829 228794 }
8830
8831 458954 void eItemFairy::draw(BITMAP *dest)
8832 {
8833 //these are here to bypass compiler warnings about unused arguments
8834 458954 dest=dest;
8835 458954 }
8836
8837 2096 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8838 2096 {
8839 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8840
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1048 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1048 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1048 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1048 times.
✗ Branch 19 not taken.
1048 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8841 1048 dir=8;
8842 1048 movestatus=1;
8843 1048 clk=0;
8844
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 step=0;
8845 //nets+720;
8846 1048 SIZEflags = d->SIZEflags;
8847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8848 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8849 // al_trace("Enemy txsz:%i\n", txsz);
8850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8854
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8855
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8856 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8859 {
8860 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8861 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8862 }
8863
8864
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8865 1048 }
8866
8867 300264 bool ePeahat::animate(int32_t index)
8868 {
8869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300264 times.
300264 if(switch_hooked) return enemy::animate(index);
8870
2/4
✓ Branch 0 taken 300264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300264 times.
300264 if(fallclk||drownclk) return enemy::animate(index);
8871
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 300186 times.
300264 if(slide())
8872 {
8873 78 return false;
8874 }
8875
8876
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 299672 times.
300186 if(dying)
8877 514 return Dead(index);
8878
8879
2/2
✓ Branch 0 taken 297855 times.
✓ Branch 1 taken 1817 times.
299672 if(clk==0)
8880 {
8881 1817 removearmos(x,y,ffcactivated);
8882 1817 }
8883
8884
4/4
✓ Branch 0 taken 296892 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 144455 times.
✓ Branch 3 taken 152437 times.
299672 if(stunclk==0 && clk>96)
8885 152437 misc=1;
8886
8887
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
299672 if(!watch)
8888
2/2
✓ Branch 0 taken 197329 times.
✓ Branch 1 taken 99941 times.
297270 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8889
8890
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 199654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
299672 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8891 {
8892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8893 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8894 100018 }
8895
8896
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
299672 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8897 1634 superman=0;
8898 else
8899
2/2
✓ Branch 0 taken 6888 times.
✓ Branch 1 taken 291150 times.
298038 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8900 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8901
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 103653 times.
299672 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8902 {
8903
2/2
✓ Branch 0 taken 193242 times.
✓ Branch 1 taken 2777 times.
196019 if ( stunclk ) --stunclk;
8904 196019 }
8905 103653 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8906 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8907
8908
8909
2/2
✓ Branch 0 taken 299448 times.
✓ Branch 1 taken 224 times.
299672 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8910
8911 299672 return enemy::animate(index);
8912 300264 }
8913
8914 126460 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8915 {
8916 126460 int32_t tempy=yofs;
8917 126460 flip = 0;
8918 126460 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8919
8920
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 38371 times.
126460 if(!get_qr(qr_ENEMIESZAXIS))
8921 {
8922 38371 yofs+=8;
8923 38371 yofs+=int32_t(step/zslongToFix(dstep*10));
8924 38371 }
8925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126460 times.
126460 if(!shadow_overpit(this))
8926 126460 enemy::drawshadow(dest,translucent);
8927 126460 yofs=tempy;
8928 126460 }
8929
8930 694948 void ePeahat::draw(BITMAP *dest)
8931 {
8932 694948 update_enemy_frame();
8933 694948 enemy::draw(dest);
8934 694948 }
8935
8936 1383 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8937 {
8938 1383 int32_t wpnId = w->id;
8939 1383 int32_t enemyHitWeapon = w->parentitem;
8940
8941
3/6
✓ Branch 0 taken 1383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1383 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1383 times.
1383 if(dying || clk<0 || hclk>0)
8942 return 0;
8943
8944
4/4
✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 129 times.
1542 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8945 // fire boomerang, for nailing peahats
8946
4/6
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✓ Branch 3 taken 159 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 159 times.
1186 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8947 1156 return 0;
8948
8949 // Time for a kludge...
8950 227 int32_t s = superman;
8951 227 superman = 0;
8952 227 int32_t ret = enemy::takehit(w,realweap);
8953 227 superman = s;
8954
8955 // Anyway...
8956
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 141 times.
227 if(stunclk == 160)
8957 {
8958 141 clk2=0;
8959 141 movestatus=0;
8960 141 misc=0;
8961 141 clk=0;
8962 141 step=0;
8963 141 }
8964
8965 227 return ret;
8966 1383 }
8967
8968 // auomatically kill off enemy (for rooms with ringleaders)
8969 void ePeahat::kickbucket()
8970 {
8971 hp=-1000; // don't call death_sfx()
8972 }
8973
8974 3388 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8975 3388 {
8976 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8977
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 941 times.
1694 if(dmisc1==0)
8978 {
8979 941 misc=-1; //Line of Sight leevers
8980 941 clk-=16;
8981 941 }
8982 1694 clk3 = 0;
8983 //nets+1460;
8984
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8985 1694 submerged = false;
8986 1694 SIZEflags = d->SIZEflags;
8987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8988 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8989 // al_trace("Enemy txsz:%i\n", txsz);
8990
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8993
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8994
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8995
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8996 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8999 {
9000 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9001 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9002 }
9003
9004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9005 1694 }
9006
9007 bool eLeever::isSubmerged() const
9008 {
9009 Z_scripterrlog("misc is: %d\n", misc);
9010 return misc <= 0;
9011
9012 }
9013
9014 499943 bool eLeever::animate(int32_t index)
9015 {
9016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 499943 times.
499943 if(switch_hooked) return enemy::animate(index);
9017
2/4
✓ Branch 0 taken 499943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 499943 times.
499943 if(fallclk||drownclk)
9018 {
9019 return enemy::animate(index);
9020 }
9021
2/2
✓ Branch 0 taken 16506 times.
✓ Branch 1 taken 483437 times.
499943 if(dying)
9022 16506 return Dead(index);
9023
9024
2/2
✓ Branch 0 taken 463097 times.
✓ Branch 1 taken 20340 times.
483437 if(clk==0)
9025 {
9026 20340 removearmos(x,y,ffcactivated);
9027 20340 }
9028
9029
4/4
✓ Branch 0 taken 393192 times.
✓ Branch 1 taken 90245 times.
✓ Branch 2 taken 2529 times.
✓ Branch 3 taken 390663 times.
483437 if(clk>=0 && !slide())
9030 {
9031 // switch(d->misc1)
9032
2/2
✓ Branch 0 taken 156396 times.
✓ Branch 1 taken 234267 times.
390663 switch(dmisc1)
9033 {
9034 case 0: //line of sight
9035 case 2:
9036
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✓ Branch 2 taken 17136 times.
✓ Branch 3 taken 15898 times.
✓ Branch 4 taken 7088 times.
✓ Branch 5 taken 43977 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 2915 times.
156396 switch(misc) //is this leever active
9037 {
9038 case -1: //submerged
9039 {
9040
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67550 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
9041
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 59941 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
67550 if((dmisc1==2)&&(zc_oldrand()&255))
9042 {
9043 7582 break;
9044 }
9045
9046 59968 int32_t active=0;
9047
9048
2/2
✓ Branch 0 taken 424896 times.
✓ Branch 1 taken 59968 times.
484864 for(int32_t i=0; i<guys.Count(); i++)
9049 {
9050
4/4
✓ Branch 0 taken 348604 times.
✓ Branch 1 taken 76292 times.
✓ Branch 2 taken 229810 times.
✓ Branch 3 taken 118794 times.
424896 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
9051 {
9052 118794 ++active;
9053 118794 }
9054 424896 }
9055
9056
2/2
✓ Branch 0 taken 59147 times.
✓ Branch 1 taken 821 times.
59968 if(active<((dmisc1==2)?1:2))
9057 {
9058 821 misc=0; //activate this one
9059 821 clk3=1; //This needs to be set so that it knows that it's being emerged of it's own will and not because it got stunned.
9060 821 }
9061 }
9062 59968 break;
9063
9064 case 0:
9065 {
9066
9067
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17136 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9068 {
9069 misc=1;
9070 clk2=0;
9071 }
9072
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17100 times.
17136 else if (clk3<=0)
9073 {
9074 36 misc = -1;
9075 36 break;
9076 }
9077 17100 int32_t s=0;
9078
9079
2/2
✓ Branch 0 taken 112208 times.
✓ Branch 1 taken 17100 times.
129308 for(int32_t i=0; i<guys.Count(); i++)
9080 {
9081
4/4
✓ Branch 0 taken 74011 times.
✓ Branch 1 taken 38197 times.
✓ Branch 2 taken 71849 times.
✓ Branch 3 taken 2162 times.
112208 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
9082 {
9083 2162 ++s;
9084 2162 }
9085 112208 }
9086
9087
2/2
✓ Branch 0 taken 2162 times.
✓ Branch 1 taken 14938 times.
17100 if(s>0)
9088 {
9089 2162 break;
9090 }
9091
9092 14938 int32_t d2=zc_oldrand()&1;
9093
9094
2/2
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 9602 times.
14938 if(HeroDir()>=left)
9095 {
9096 9602 d2+=2;
9097 9602 }
9098
9099
4/4
✓ Branch 0 taken 14295 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 13995 times.
14938 if(canplace(d2) || canplace(d2^1))
9100 {
9101 943 misc=1;
9102 943 clk2=0;
9103 943 clk=0;
9104 943 }
9105 }
9106 14938 break;
9107
9108 case 1:
9109
9110
3/8
✓ Branch 0 taken 14970 times.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14970 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15898 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9111
9112 15898 break;
9113
9114 case 2:
9115
9116
3/8
✓ Branch 0 taken 6227 times.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6227 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7088 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9117
9118 7088 break;
9119
9120 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9121 case 3:
9122
9123
5/6
✓ Branch 0 taken 41679 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 41679 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 39613 times.
43977 if(stunclk || frozenclock || watch) break;
9124
9125
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39534 times.
39613 if(scored) dir^=1;
9126
9127
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39402 times.
39613 if(!canmove(dir,false)) misc=4;
9128 39402 else move(zslongToFix(dstep*100));
9129
9130 39613 break;
9131
9132 case 4:
9133
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1832 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9134
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 197 times.
1832 if(--clk2<=16)
9135 {
9136 197 misc=5;
9137 197 clk=8;
9138 197 }
9139
9140 1832 break;
9141
9142 case 5:
9143
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2915 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9144
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 175 times.
2915 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9145
9146 2915 break;
9147 } // switch(misc)
9148
9149 156396 break;
9150
9151 default: //random
9152 // step=d->misc3/100.0;
9153
9154 234267 step=zslongToFix(dmisc3*100);
9155
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
234267 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9156 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9157 {
9158 if (clk2 < 48) clk2+=2;
9159 if (clk2 >= 300) clk2-=2;
9160 }
9161
9162
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 206748 times.
234267 if(clk2<32) misc=1;
9163
2/2
✓ Branch 0 taken 13816 times.
✓ Branch 1 taken 192932 times.
206748 else if(clk2<48) misc=2;
9164
2/2
✓ Branch 0 taken 140831 times.
✓ Branch 1 taken 52101 times.
192932 else if(clk2<300)
9165 {
9166 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9167 {
9168 fix_coords();
9169 }*/
9170 140831 misc=3;
9171 140831 step = zslongToFix(dstep*100);
9172 140831 }
9173
2/2
✓ Branch 0 taken 4801 times.
✓ Branch 1 taken 47300 times.
52101 else if(clk2<316) misc=2;
9174
2/2
✓ Branch 0 taken 23641 times.
✓ Branch 1 taken 23659 times.
47300 else if(clk2<412) misc=1;
9175
2/2
✓ Branch 0 taken 23490 times.
✓ Branch 1 taken 169 times.
23659 else if(clk2<540)
9176 {
9177 23490 misc=0;
9178 23490 step=0;
9179 23490 }
9180 169 else clk2=0;
9181
9182
2/2
✓ Branch 0 taken 233418 times.
✓ Branch 1 taken 849 times.
234267 if(clk2==48) clk=0;
9183
9184 // variable_walk(d->rate, d->homing, 0);
9185 234267 variable_walk(rate, homing, 0);
9186 234267 } // switch(dmisc1)
9187 390663 }
9188
9189 483437 hxofs=(misc>=2)?0:1000;
9190 483437 return enemy::animate(index);
9191 499943 }
9192
9193 29233 bool eLeever::canplace(int32_t d2)
9194 {
9195 29233 int32_t nx=HeroX();
9196 29233 int32_t ny=HeroY();
9197
9198
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 18829 times.
29233 if(d2<left) ny&=0xF0;
9199 18829 else nx&=0xF0;
9200
9201
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
✓ Branch 2 taken 5231 times.
✓ Branch 3 taken 9395 times.
✓ Branch 4 taken 9434 times.
29233 switch(d2)
9202 {
9203 // case up: ny-=((d->misc1==0)?32:48); break;
9204 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9205 // case left: nx-=((d->misc1==0)?32:48); break;
9206 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9207 case up:
9208
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 28 times.
5173 ny-=((dmisc1==0||dmisc1==2)?32:48);
9209 5173 break;
9210
9211 case down:
9212
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5200 times.
5231 ny+=((dmisc1==0||dmisc1==2)?32:48);
9213
9214
4/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 9 times.
5231 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9215
9216 5231 break;
9217
9218 case left:
9219
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 600 times.
9395 nx-=((dmisc1==0||dmisc1==2)?32:48);
9220 9395 break;
9221
9222 case right:
9223
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8839 times.
9434 nx+=((dmisc1==0||dmisc1==2)?32:48);
9224
9225
4/4
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5499 times.
✓ Branch 3 taken 555 times.
9434 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9226
9227 9434 break;
9228 }
9229
9230
4/4
✓ Branch 0 taken 10020 times.
✓ Branch 1 taken 19213 times.
✓ Branch 2 taken 4483 times.
✓ Branch 3 taken 5537 times.
29233 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9231 23696 return false;
9232
9233
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5098 times.
5537 if(d2>=left)
9234
4/4
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 2617 times.
✓ Branch 2 taken 4594 times.
✓ Branch 3 taken 504 times.
5098 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9235 4594 return false;
9236
9237 943 x=nx;
9238 943 y=ny;
9239 943 dir=d2^1;
9240 943 return true;
9241 29233 }
9242
9243 500779 void eLeever::draw(BITMAP *dest)
9244 {
9245 // cs=d->cset;
9246 500779 cs=dcset;
9247 500779 update_enemy_frame();
9248
2/4
✓ Branch 0 taken 500779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500779 times.
500779 if(!fallclk&&!drownclk)
9249 {
9250
2/2
✓ Branch 0 taken 301145 times.
✓ Branch 1 taken 199634 times.
500779 switch(misc)
9251 {
9252 case -1:
9253 case 0:
9254 199634 return;
9255 }
9256 301145 }
9257
9258 301145 enemy::draw(dest);
9259 500779 }
9260
9261 1046 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9262 1046 {
9263 //zprint2("eWallM::eWallM\n");
9264 523 hashero=false;
9265 //nets+1000;
9266 523 SIZEflags = d->SIZEflags;
9267
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9268 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9269 // al_trace("Enemy txsz:%i\n", txsz);
9270
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9274
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9275
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9276 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9277
1/4
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9279 {
9280 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9281 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9282 }
9283
9284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9285 523 }
9286
9287 321974 bool eWallM::animate(int32_t index)
9288 {
9289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 321974 times.
321974 if(switch_hooked) return enemy::animate(index);
9290
2/4
✓ Branch 0 taken 321974 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321974 times.
321974 if(fallclk||drownclk)
9291 {
9292 return enemy::animate(index);
9293 }
9294
2/2
✓ Branch 0 taken 6282 times.
✓ Branch 1 taken 315692 times.
321974 if(dying)
9295 6282 return Dead(index);
9296
9297
2/2
✓ Branch 0 taken 295632 times.
✓ Branch 1 taken 20060 times.
315692 if(clk==0)
9298 {
9299 20060 removearmos(x,y,ffcactivated);
9300 20060 }
9301
9302 315692 hxofs=1000;
9303
2/2
✓ Branch 0 taken 81640 times.
✓ Branch 1 taken 234052 times.
315692 if(misc==0) //inside wall, ready to spawn?
9304 {
9305 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
9306 //zprint2("frame is: %d\n",frame);
9307 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
9308
4/4
✓ Branch 0 taken 154566 times.
✓ Branch 1 taken 79486 times.
✓ Branch 2 taken 9024 times.
✓ Branch 3 taken 145542 times.
234052 if(frame-wallm_load_clk>80 && clk>=0)
9309 {
9310 //zprint2("getting wall\n");
9311 145542 int32_t wall=hero_on_wall();
9312 //zprint2("Wallmaster wall is %d\n",wall);
9313 145542 int32_t wallm_cnt=0;
9314
9315
2/2
✓ Branch 0 taken 1108757 times.
✓ Branch 1 taken 145542 times.
1254299 for(int32_t i=0; i<guys.Count(); i++)
9316
2/2
✓ Branch 0 taken 421543 times.
✓ Branch 1 taken 687214 times.
1795971 if(((enemy*)guys.spr(i))->family==eeWALLM)
9317 {
9318 687214 int32_t m=((enemy*)guys.spr(i))->misc;
9319
9320
4/4
✓ Branch 0 taken 32180 times.
✓ Branch 1 taken 655034 times.
✓ Branch 2 taken 20369 times.
✓ Branch 3 taken 11811 times.
687214 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9321 {
9322 11811 ++wallm_cnt;
9323 11811 }
9324 687214 }
9325
9326
2/2
✓ Branch 0 taken 145029 times.
✓ Branch 1 taken 513 times.
145542 if(wall>0)
9327 {
9328 513 --wall;
9329 513 misc=1; //emerging from the wall?
9330 //zprint2("Wallmaster is emerging\n");
9331 513 clk2=0;
9332 513 clk3=wall^1;
9333 513 wallm_load_clk=frame;
9334
9335
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 201 times.
513 if(wall<=down)
9336 {
9337
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 258 times.
312 if(HeroDir()==left)
9338 54 dir=right;
9339 else
9340 258 dir=left;
9341 312 }
9342 else
9343 {
9344
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 162 times.
201 if(HeroDir()==up)
9345 39 dir=down;
9346 else
9347 162 dir=up;
9348 }
9349
9350
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 69 times.
513 switch(wall)
9351 {
9352 case up:
9353 152 y=0;
9354 152 break;
9355
9356 case down:
9357 160 y=160;
9358 160 break;
9359
9360 case left:
9361 132 x=0;
9362 132 break;
9363
9364 case right:
9365 69 x=240;
9366 69 break;
9367 }
9368
9369 //zprint2("Wallmaster (p1) x is %d\n",x);
9370 //zprint2("Wallmaster (p1) y is %d\n",y);
9371
9372
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 54 times.
513 switch(dir)
9373 {
9374 case up:
9375 162 y=(HeroY()+48-(wallm_cnt&1)*12);
9376 162 flip=wall&1;
9377 162 break;
9378
9379 case down:
9380 39 y=(HeroY()-48+(wallm_cnt&1)*12);
9381 39 flip=((wall&1)^1)+2;
9382 39 break;
9383
9384 case left:
9385 258 x=(HeroX()+48-(wallm_cnt&1)*12);
9386 258 flip=(wall==up?2:0)+1;
9387 258 break;
9388
9389 case right:
9390 54 x=(HeroX()-48+(wallm_cnt&1)*12);
9391 54 flip=(wall==up?2:0);
9392 54 break;
9393 }
9394
9395 //zprint2("Wallmaster (p2) x is %d\n",x);
9396 //zprint2("Wallmaster (p2) y is %d\n",y);
9397 513 }
9398 145542 }
9399 234052 }
9400 else
9401 81640 wallm_crawl();
9402
9403 315692 return enemy::animate(index);
9404 321974 }
9405
9406 81640 void eWallM::wallm_crawl()
9407 {
9408 81640 bool w=watch;
9409 81640 hxofs=0;
9410
9411
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 81049 times.
81640 if(slide())
9412 {
9413 591 return;
9414 }
9415
9416 // if(dying || watch || (!hashero && stunclk))
9417
6/8
✓ Branch 0 taken 81049 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80760 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 66702 times.
✓ Branch 5 taken 14058 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66702 times.
81049 if(dying || (!hashero && ( stunclk || frozenclock )))
9418 {
9419 14058 return;
9420 }
9421
9422 66991 watch=false;
9423 66991 ++clk2;
9424 // Misc1: slightly different movement
9425 //zprint2("wallmaster crawl\n");
9426 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
9427 66991 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9428
9429 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9430 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
9431 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
9432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66991 times.
66991 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9433 //zprint2("wallmaster crawl misc is: %d\n", misc);
9434
5/6
✓ Branch 0 taken 5942 times.
✓ Branch 1 taken 61049 times.
✓ Branch 2 taken 4472 times.
✓ Branch 3 taken 1470 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4472 times.
66991 if(w&&misc>=3&&misc<=5)
9435 {
9436 4472 --clk2;
9437 4472 }
9438
9439
4/4
✓ Branch 0 taken 28236 times.
✓ Branch 1 taken 31313 times.
✓ Branch 2 taken 7328 times.
✓ Branch 3 taken 114 times.
66991 switch(misc)
9440 {
9441 case 1:
9442 case 2:
9443 31313 zc_swap(dir,clk3);
9444 31313 move(step);
9445 31313 zc_swap(dir,clk3);
9446 31313 break;
9447
9448 case 3:
9449 case 4:
9450 case 5:
9451
2/2
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 23764 times.
28236 if(w)
9452 {
9453 4472 watch=w;
9454 4472 return;
9455 }
9456
9457 23764 move(step);
9458 23764 break;
9459
9460 case 6:
9461 case 7:
9462 7328 zc_swap(dir,clk3);
9463 7328 dir^=1;
9464 7328 move(step);
9465 7328 dir^=1;
9466 7328 zc_swap(dir,clk3);
9467 7328 break;
9468
9469 default:
9470 114 misc=0;
9471 114 break;
9472 }
9473
9474 62519 watch=w;
9475 81640 }
9476
9477 3 void eWallM::grabhero()
9478 {
9479 3 hashero=true;
9480 3 superman=1;
9481 3 }
9482
9483 322782 void eWallM::draw(BITMAP *dest)
9484 {
9485 322782 dummy_bool[1]=hashero;
9486 322782 update_enemy_frame();
9487
9488
4/6
✓ Branch 0 taken 234569 times.
✓ Branch 1 taken 88213 times.
✓ Branch 2 taken 234569 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234569 times.
322782 if(misc>0 || fallclk||drownclk)
9489 {
9490 88213 masked_draw(dest,16,playing_field_offset+16,224,144);
9491 88213 }
9492
9493 // enemy::draw(dest);
9494 // tile = clk&8 ? 128:129;
9495 322782 }
9496
9497 bool eWallM::isSubmerged() const
9498 {
9499 return ( !misc );
9500 }
9501
9502 1484 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9503 1484 {
9504
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 ox=x; //original x
9505
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 oy=y; //original y
9506
3/4
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 676 times.
742 if(get_qr(qr_TRAPPOSFIX))
9507 {
9508
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9509 66 }
9510
9511 742 mainguy=false;
9512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9513 //nets+420;
9514 742 dummy_int[1]=0;
9515 742 SIZEflags = d->SIZEflags;
9516
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9517 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9518 // al_trace("Enemy txsz:%i\n", txsz);
9519
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9521
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9522
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9523
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9524
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9525 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9528 {
9529 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9530 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9531 }
9532
9533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9534 742 }
9535
9536 534456 bool eTrap::animate(int32_t index)
9537 {
9538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 534456 times.
534456 if(switch_hooked) return enemy::animate(index);
9539
2/4
✓ Branch 0 taken 534456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 534456 times.
534456 if(fallclk||drownclk) return enemy::animate(index);
9540
2/2
✓ Branch 0 taken 524072 times.
✓ Branch 1 taken 10384 times.
534456 if(clk<0)
9541 10384 return enemy::animate(index);
9542
9543
2/2
✓ Branch 0 taken 490954 times.
✓ Branch 1 taken 33118 times.
524072 if(clk==0)
9544 {
9545 33118 removearmos(x,y,ffcactivated);
9546 33118 }
9547
9548
2/2
✓ Branch 0 taken 142952 times.
✓ Branch 1 taken 381120 times.
524072 if(misc==0) // waiting
9549 {
9550 381120 ox = x;
9551 381120 oy = y;
9552 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9553 381120 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9554
9555
4/4
✓ Branch 0 taken 127495 times.
✓ Branch 1 taken 253625 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 53982 times.
381120 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9556 {
9557 53982 dir=down;
9558 53982 }
9559
4/4
✓ Branch 0 taken 220423 times.
✓ Branch 1 taken 106715 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 146910 times.
327138 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9560 {
9561 146910 dir=right;
9562 146910 }
9563
4/4
✓ Branch 0 taken 112988 times.
✓ Branch 1 taken 67240 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 39475 times.
180228 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9564 {
9565 39475 dir=up;
9566 39475 }
9567 else
9568 {
9569 140753 dir=left;
9570 }
9571
9572 381120 int32_t d2=lined_up(15,true);
9573
9574
4/4
✓ Branch 0 taken 135666 times.
✓ Branch 1 taken 245454 times.
✓ Branch 2 taken 684811 times.
✓ Branch 3 taken 303691 times.
615292 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9575
2/2
✓ Branch 0 taken 129243 times.
✓ Branch 1 taken 174448 times.
303691 ((d2>down) && (dmisc1==2)) ||
9576
2/2
✓ Branch 0 taken 118337 times.
✓ Branch 1 taken 83129 times.
174448 ((d2>right) && (!dmisc1)) ||
9577
2/2
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 38204 times.
201466 ((d2<l_up) && (dmisc1==4)) ||
9578
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 195968 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
38204 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9579
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 38204 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
195968 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9580 {
9581 1516570 d2=-1;
9582 1516570 }
9583
9584
4/4
✓ Branch 0 taken 11339 times.
✓ Branch 1 taken 173813 times.
✓ Branch 2 taken 10273 times.
✓ Branch 3 taken 1066 times.
185152 if(d2!=-1 && trapmove(d2))
9585 {
9586 1066 dir=d2;
9587 1066 misc=1;
9588 1066 clk2=(dir==down)?3:0;
9589 1066 }
9590 185152 }
9591
9592
2/2
✓ Branch 0 taken 289443 times.
✓ Branch 1 taken 38661 times.
328104 if(misc==1) // charging
9593 {
9594 38661 clk2=(clk2+1)&3;
9595 38661 step=(clk2==3)?1:2;
9596
9597
4/4
✓ Branch 0 taken 38531 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 860 times.
✓ Branch 3 taken 37671 times.
38661 if(!trapmove(dir) || clip())
9598 {
9599 990 misc=2;
9600
9601
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if(dir<l_up)
9602 {
9603 990 dir=dir^1;
9604 990 }
9605 else
9606 {
9607 dir=dir^3;
9608 }
9609 990 }
9610 else
9611 {
9612 37671 sprite::move(step);
9613 }
9614 38661 }
9615
9616
2/2
✓ Branch 0 taken 221757 times.
✓ Branch 1 taken 106347 times.
328104 if(misc==2) // retreating
9617 {
9618 106347 step=(++clk2&1)?1:0;
9619
9620
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 17320 times.
✓ Branch 2 taken 39848 times.
✓ Branch 3 taken 11903 times.
✓ Branch 4 taken 37276 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106347 switch(dir)
9621 {
9622 case up:
9623
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 17181 times.
17320 if(int32_t(y)<=oy) goto trap_rest;
9624 17181 else sprite::move(step);
9625
9626 17181 break;
9627
9628 case left:
9629
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 39620 times.
39848 if(int32_t(x)<=ox) goto trap_rest;
9630 39620 else sprite::move(step);
9631
9632 39620 break;
9633
9634 case down:
9635
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 11791 times.
11903 if(int32_t(y)>=oy) goto trap_rest;
9636 11791 else sprite::move(step);
9637
9638 11791 break;
9639
9640 case right:
9641
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 37049 times.
37276 if(int32_t(x)>=ox) goto trap_rest;
9642 37049 else sprite::move(step);
9643
9644 37049 break;
9645
9646 case l_up:
9647 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9648 else sprite::move(step);
9649
9650 break;
9651
9652 case r_up:
9653 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9654 else sprite::move(step);
9655
9656 break;
9657
9658 case l_down:
9659 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9660 else sprite::move(step);
9661
9662 break;
9663
9664 case r_down:
9665 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9666 else sprite::move(step);
9667
9668 break;
9669 trap_rest:
9670 {
9671 706 x=ox;
9672 706 y=oy;
9673 706 misc=0;
9674 }
9675 706 }
9676 106347 }
9677
9678 328104 return enemy::animate(index);
9679 338488 }
9680
9681 50000 bool eTrap::trapmove(int32_t ndir)
9682 {
9683
2/2
✓ Branch 0 taken 35733 times.
✓ Branch 1 taken 14267 times.
50000 if(get_qr(qr_MEANTRAPS))
9684 {
9685
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 34393 times.
35733 if(tmpscr->flags2&fFLOATTRAPS)
9686 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9687
9688 34393 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9689 }
9690
9691
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
9692 2766 return false;
9693
9694
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
9695 return false;
9696
9697
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
9698 return false;
9699
9700
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
9701 return false;
9702
9703
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
9704 718 return false;
9705
9706
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
9707 488 return false;
9708
9709
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
9710 return false;
9711
9712
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
9713 return false;
9714
9715
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
9716 return false;
9717
9718
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
9719 return false;
9720
9721 10295 return true;
9722 50000 }
9723
9724 38531 bool eTrap::clip()
9725 {
9726
2/2
✓ Branch 0 taken 33513 times.
✓ Branch 1 taken 5018 times.
38531 if(get_qr(qr_MEANPLACEDTRAPS))
9727 {
9728
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✓ Branch 2 taken 1926 times.
✓ Branch 3 taken 985 times.
✓ Branch 4 taken 1377 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5018 switch(dir)
9729 {
9730 case up:
9731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
730 if(y<=0) return true;
9732
9733 730 break;
9734
9735 case down:
9736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1926 times.
1926 if(y>=160) return true;
9737
9738 1926 break;
9739
9740 case left:
9741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985 times.
985 if(x<=0) return true;
9742
9743 985 break;
9744
9745 case right:
9746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(x>=240) return true;
9747
9748 1377 break;
9749
9750 case l_up:
9751 if(y<=0||x<=0) return true;
9752
9753 break;
9754
9755 case l_down:
9756 if(y>=160||x<=0) return true;
9757
9758 break;
9759
9760 case r_up:
9761 if(y<=0||x>=240) return true;
9762
9763 break;
9764
9765 case r_down:
9766 if(y>=160||x>=240) return true;
9767
9768 break;
9769 }
9770
9771 5018 return false;
9772 }
9773 else
9774 {
9775
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
✓ Branch 2 taken 4135 times.
✓ Branch 3 taken 12605 times.
✓ Branch 4 taken 13028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33513 switch(dir)
9776 {
9777 case up:
9778
4/4
✓ Branch 0 taken 3691 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3546 times.
✓ Branch 3 taken 145 times.
3745 if(oy>80 && y<=86) return true;
9779
9780 3600 break;
9781
9782 case down:
9783
4/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 151 times.
4135 if(oy<80 && y>=80) return true;
9784
9785 3984 break;
9786
9787 case left:
9788
4/4
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 12236 times.
✓ Branch 3 taken 279 times.
12605 if(ox>128 && x<=124) return true;
9789
9790 12326 break;
9791
9792 case right:
9793
3/4
✓ Branch 0 taken 13028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12743 times.
✓ Branch 3 taken 285 times.
13028 if(ox<120 && x>=116) return true;
9794
9795 12743 break;
9796
9797 case l_up:
9798 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9799
9800 break;
9801
9802 case l_down:
9803 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9804
9805 break;
9806
9807 case r_up:
9808 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9809
9810 break;
9811
9812 case r_down:
9813 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9814
9815 break;
9816 }
9817
9818 32653 return false;
9819 }
9820 38531 }
9821
9822 537872 void eTrap::draw(BITMAP *dest)
9823 {
9824 537872 update_enemy_frame();
9825 537872 enemy::draw(dest);
9826 537872 }
9827
9828 2407 int32_t eTrap::takehit(weapon*,weapon*)
9829 {
9830 2407 return 0;
9831 }
9832
9833 294 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9834 294 {
9835 147 lasthit=-1;
9836 147 lasthitclk=0;
9837 147 mainguy=false;
9838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9839
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 step=2;
9840
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9841 {
9842
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 dir=(x<=112)?right:left;
9843 67 }
9844 else
9845 {
9846
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
9847 }
9848
9849
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
147 if(get_qr(qr_TRAPPOSFIX))
9850 {
9851 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9852 }
9853
9854 //nets+((id==eTRAP_LR)?540:520);
9855 147 dummy_int[1]=0;
9856 147 SIZEflags = d->SIZEflags;
9857
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9858 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9859 // al_trace("Enemy txsz:%i\n", txsz);
9860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9864
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9865
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9866 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9867
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9869 {
9870 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9871 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9872 }
9873
9874
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9875 147 }
9876
9877 85467 bool eTrap2::animate(int32_t index)
9878 {
9879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85467 times.
85467 if(switch_hooked) return enemy::animate(index);
9880
2/4
✓ Branch 0 taken 85467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85467 times.
85467 if(fallclk||drownclk) return enemy::animate(index);
9881
2/2
✓ Branch 0 taken 83409 times.
✓ Branch 1 taken 2058 times.
85467 if(clk<0)
9882 2058 return enemy::animate(index);
9883
9884
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 78120 times.
83409 if(clk==0)
9885 {
9886 5289 removearmos(x,y,ffcactivated);
9887 5289 }
9888
9889
2/2
✓ Branch 0 taken 79017 times.
✓ Branch 1 taken 4392 times.
83409 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9890 {
9891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
9892 {
9893 --lasthitclk;
9894 }
9895 else
9896 {
9897 4392 lasthit=-1;
9898 }
9899
9900 4392 bool hitenemy=false;
9901
9902
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
9903 {
9904
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
9905 {
9906
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
9907 {
9908 lasthit=j;
9909 lasthitclk=10;
9910 hitenemy=true;
9911 guys.spr(j)->lasthit=index;
9912 guys.spr(j)->lasthitclk=10;
9913 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9914 }
9915 52704 }
9916 57096 }
9917
9918
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
9919 {
9920
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
9921 {
9922 48 lasthit=-1;
9923 48 lasthitclk=0;
9924 48 }
9925
9926
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_qr(qr_MORESOUNDS))
9927 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9928
9929 48 dir=dir^1;
9930 48 }
9931
9932 4392 sprite::move(step);
9933 4392 }
9934 else
9935 {
9936
3/4
✓ Branch 0 taken 77234 times.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77234 times.
79017 if(!trapmove(dir) || clip())
9937 {
9938
1/2
✓ Branch 0 taken 1783 times.
✗ Branch 1 not taken.
1783 if(get_qr(qr_MORESOUNDS))
9939 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9940
9941 1783 dir=dir^1;
9942 1783 }
9943
9944 79017 sprite::move(step);
9945 }
9946
9947 83409 return enemy::animate(index);
9948 85467 }
9949
9950 83457 bool eTrap2::trapmove(int32_t ndir)
9951 {
9952
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 81579 times.
83457 if(tmpscr->flags2&fFLOATTRAPS)
9953 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9954
9955 81579 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9956 83457 }
9957
9958 81578 bool eTrap2::clip()
9959 {
9960
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 17291 times.
✓ Branch 4 taken 17524 times.
81578 switch(dir)
9961 {
9962 case up:
9963
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
9964
9965 23387 break;
9966
9967 case down:
9968
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
9969
9970 23376 break;
9971
9972 case left:
9973
1/2
✓ Branch 0 taken 17291 times.
✗ Branch 1 not taken.
17291 if(x<=0) return true;
9974
9975 17291 break;
9976
9977 case right:
9978
1/2
✓ Branch 0 taken 17524 times.
✗ Branch 1 not taken.
17524 if(x>=240) return true;
9979
9980 17524 break;
9981 }
9982
9983 81578 return false;
9984 81578 }
9985
9986 85478 void eTrap2::draw(BITMAP *dest)
9987 {
9988 85478 update_enemy_frame();
9989 85478 enemy::draw(dest);
9990 85478 }
9991
9992 531 int32_t eTrap2::takehit(weapon*,weapon*)
9993 {
9994 531 return 0;
9995 }
9996
9997 452 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9998 452 {
9999 //do not show "enemy appering" anim -DD
10000 226 clk=0;
10001 226 mainguy=false;
10002 226 clk2=-14;
10003 //Enemy Editor Size Tab
10004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10005 226 else hxofs = -2;
10006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10007 226 else hyofs = -2;
10008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10009 226 else hit_width = 20;
10010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10011 226 else hit_height=20;
10012
10013
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10014
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10016
1/4
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10018 {
10019 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10020 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10021 }
10022
10023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10024 //nets+1640;
10025 226 }
10026
10027 79036 bool eRock::animate(int32_t index)
10028 {
10029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(switch_hooked) return enemy::animate(index);
10030
2/4
✓ Branch 0 taken 79036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79036 times.
79036 if(fallclk||drownclk) return enemy::animate(index);
10031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(dying)
10032 return Dead(index);
10033
10034
2/2
✓ Branch 0 taken 73519 times.
✓ Branch 1 taken 5517 times.
79036 if(clk==0)
10035 {
10036 5517 removearmos(x,y,ffcactivated);
10037 5517 }
10038
10039
2/2
✓ Branch 0 taken 78591 times.
✓ Branch 1 taken 445 times.
79036 if(++clk2==0) // start it
10040 {
10041 445 x=zc_oldrand()&0xF0;
10042 445 y=0;
10043 445 clk3=0;
10044 445 clk2=zc_oldrand()&15;
10045 445 }
10046
10047
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 64376 times.
79036 if(clk2>16) // move it
10048 {
10049
2/2
✓ Branch 0 taken 62155 times.
✓ Branch 1 taken 2221 times.
64376 if(clk3<=0) // start bounce
10050 {
10051 2221 dir=zc_oldrand()&1;
10052
10053
2/2
✓ Branch 0 taken 1966 times.
✓ Branch 1 taken 255 times.
2221 if(x<32) dir=1;
10054
10055
2/2
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 181 times.
2221 if(x>208) dir=0;
10056 2221 }
10057
10058
2/2
✓ Branch 0 taken 62303 times.
✓ Branch 1 taken 2073 times.
64376 if(clk3<13+16)
10059 {
10060 62303 x += dir ? 1 : -1; //right, left
10061 62303 dummy_int[1]=dir;
10062
10063
2/2
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 57867 times.
62303 if(clk3<2)
10064 {
10065 4436 y-=2; //up
10066 4436 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10067 4436 }
10068
2/2
✓ Branch 0 taken 6614 times.
✓ Branch 1 taken 51253 times.
57867 else if(clk3<5)
10069 {
10070 6614 y--; //up
10071 6614 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10072 6614 }
10073
2/2
✓ Branch 0 taken 6569 times.
✓ Branch 1 taken 44684 times.
51253 else if(clk3<8)
10074 {
10075 6569 dummy_int[2]=(dummy_int[1]==1)?right:left;
10076 6569 }
10077
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 38166 times.
44684 else if(clk3<11)
10078 {
10079 6518 y++; //down
10080 6518 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10081 6518 }
10082 else
10083 {
10084 38166 y+=2; //down
10085 38166 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10086 }
10087
10088 62303 ++clk3;
10089 62303 }
10090
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 280 times.
2073 else if(y<176)
10091 1793 clk3=0; // next bounce
10092 else
10093 280 clk2 = -(zc_oldrand()&63); // back to top
10094 64376 }
10095
10096 79036 return enemy::animate(index);
10097 79036 }
10098
10099 21684 void eRock::drawshadow(BITMAP *dest, bool translucent)
10100 {
10101
2/2
✓ Branch 0 taken 2969 times.
✓ Branch 1 taken 18715 times.
21684 if(clk2>=0)
10102 {
10103 18715 int32_t tempy=yofs;
10104 18715 flip = 0;
10105 18715 int32_t fdiv = frate/4;
10106
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10107
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t f2=get_qr(qr_NEWENEMYTILES)?
10108 18715 efrate:((clk>=(frate>>1))?1:0);
10109 18715 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10110
10111 18715 yofs+=8;
10112
5/6
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 9957 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18715 times.
✓ Branch 4 taken 8758 times.
✓ Branch 5 taken 9957 times.
18715 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715 times.
18715 if(!shadow_overpit(this))
10114 18715 enemy::drawshadow(dest, translucent);
10115 18715 yofs=tempy;
10116 18715 }
10117 21684 }
10118
10119 79097 void eRock::draw(BITMAP *dest)
10120 {
10121
4/6
✓ Branch 0 taken 10969 times.
✓ Branch 1 taken 68128 times.
✓ Branch 2 taken 10969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10969 times.
79097 if(clk2>=0 || fallclk||drownclk)
10122 {
10123 68128 int32_t tempdir=dir;
10124 68128 dir=dummy_int[2];
10125 68128 update_enemy_frame();
10126 68128 enemy::draw(dest);
10127 68128 dir=tempdir;
10128 68128 }
10129 79097 }
10130
10131 859 int32_t eRock::takehit(weapon*,weapon*)
10132 {
10133 859 return 0;
10134 }
10135
10136 60 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10137 60 {
10138 30 clk=0;
10139 30 mainguy=false;
10140 30 clk2=-14;
10141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10142 30 else hxofs= -10;
10143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10144 30 else hyofs=-10;
10145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10146 30 else hit_width=36;
10147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10148 30 else hit_height=36;
10149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10150 30 else hzsz=16; //can't be jumped
10151
10152
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10153
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10155
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10157 {
10158 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10159 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10160 }
10161
10162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10163 //nets+1680;
10164 30 }
10165
10166 4440 bool eBoulder::animate(int32_t index)
10167 {
10168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
10169
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
10171 return Dead(index);
10172
10173
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
10174 {
10175 290 removearmos(x,y,ffcactivated);
10176 290 }
10177
10178 zfix *vert;
10179
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10180
10181
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10182 {
10183 32 x=zc_oldrand()&0xF0;
10184 32 y=-32;
10185 32 clk3=0;
10186 32 clk2=zc_oldrand()&15;
10187 32 }
10188
10189
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10190 {
10191
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10192 {
10193 131 dir=zc_oldrand()&1;
10194
10195
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10196
10197
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10198 131 }
10199
10200
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10201 {
10202 3487 x += dir ? 1 : -1; //right, left
10203 3487 dummy_int[1]=dir;
10204
10205
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10206 {
10207 261 y-=2; //up
10208 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10209 261 }
10210
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10211 {
10212 382 y--; //up
10213 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10214 382 }
10215
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10216 {
10217 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10218 376 }
10219
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10220 {
10221 367 y++; //down
10222 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10223 367 }
10224 else
10225 {
10226 2101 y+=2; //down
10227 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10228 }
10229
10230 3487 ++clk3;
10231 3487 }
10232
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10233 101 clk3=0; // next bounce
10234 else
10235 10 clk2 = -(zc_oldrand()&63); // back to top
10236 3598 }
10237
10238 4440 return enemy::animate(index);
10239 4440 }
10240
10241 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10242 {
10243
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10244 {
10245 3868 int32_t tempy=yofs;
10246 3868 flip = 0;
10247 3868 int32_t f2=((clk<<2)/frate)<<1;
10248 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10249
5/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3868 times.
✓ Branch 4 taken 1729 times.
✓ Branch 5 taken 2139 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10250
10251 3868 yofs+=8;
10252 3868 xofs-=8;
10253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10254 3868 enemy::drawshadow(dest, translucent);
10255 3868 xofs+=16;
10256 3868 ++shadowtile;
10257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10258 3868 enemy::drawshadow(dest, translucent);
10259 3868 yofs+=16;
10260 3868 shadowtile+=20;
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10262 3868 enemy::drawshadow(dest, translucent);
10263 3868 xofs-=16;
10264 3868 --shadowtile;
10265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10266 3868 enemy::drawshadow(dest, translucent);
10267 3868 xofs+=8;
10268 3868 yofs=tempy;
10269 3868 }
10270 4440 }
10271
10272 4440 void eBoulder::draw(BITMAP *dest)
10273 {
10274
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10275 {
10276 3868 int32_t tempdir=dir;
10277 3868 dir=dummy_int[2];
10278 3868 update_enemy_frame();
10279 3868 dir=tempdir;
10280 3868 xofs-=8;
10281 3868 yofs-=8;
10282 3868 drawblock(dest,15);
10283 3868 xofs+=8;
10284 3868 yofs+=8;
10285 // enemy::draw(dest);
10286 3868 }
10287 4440 }
10288
10289 int32_t eBoulder::takehit(weapon*,weapon*)
10290 {
10291 return 0;
10292 }
10293
10294 4514 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10295
3/4
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1743 times.
2257 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10296 4514 {
10297 /* fixing
10298 hp=1;
10299 */
10300 2257 mainguy=false;
10301
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10302 2257 hclk=clk; // the "no fire" range
10303 2257 clk=0;
10304 2257 clk3=96;
10305 2257 timer=0;
10306
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if(o_tile==0)
10307 {
10308 2250 superman=1;
10309 2250 hxofs=1000;
10310 2250 }
10311 2257 SIZEflags = d->SIZEflags;
10312
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10313 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10314 // al_trace("Enemy txsz:%i\n", txsz);
10315
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10316
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10319
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10320
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10321 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10322
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10324 {
10325 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10326 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10327 }
10328
10329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10330 2257 }
10331
10332 1551984 bool eProjectile::animate(int32_t index)
10333 {
10334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1551984 times.
1551984 if(switch_hooked) return enemy::animate(index);
10335
2/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1551984 times.
1551984 if(fallclk||drownclk) return enemy::animate(index);
10336
2/2
✓ Branch 0 taken 1544504 times.
✓ Branch 1 taken 7480 times.
1551984 if(clk==0)
10337 {
10338 7480 removearmos(x,y,ffcactivated);
10339 7480 }
10340
10341 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10342 1551984 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10343
10344
4/4
✓ Branch 0 taken 507924 times.
✓ Branch 1 taken 1044060 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 229115 times.
1551984 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10345 {
10346 229115 dir=down;
10347 229115 }
10348
4/4
✓ Branch 0 taken 850200 times.
✓ Branch 1 taken 472669 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 571391 times.
1322869 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10349 {
10350 571391 dir=right;
10351 571391 }
10352
4/4
✓ Branch 0 taken 519744 times.
✓ Branch 1 taken 231734 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 240935 times.
751478 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10353 {
10354 240935 dir=up;
10355 240935 }
10356 else
10357 {
10358 510543 dir=left;
10359 }
10360
10361
3/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 812552 times.
✓ Branch 3 taken 739432 times.
1551984 if(!stunclk && ++clk3>80)
10362 {
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 739432 times.
739432 if(dmisc1==9) // Breath type
10364 {
10365 if(timer==0)
10366 {
10367 unsigned r=zc_oldrand();
10368
10369 if(!(r&63))
10370 {
10371 timer=zc_oldrand()%50+50;
10372 }
10373 }
10374
10375 if(timer>0)
10376 {
10377 if(timer%4==0)
10378 {
10379 FireBreath(false);
10380 }
10381
10382 if(--timer==0)
10383 {
10384 clk3=0;
10385 }
10386 }
10387 }
10388
10389 else // Not breath type
10390 {
10391 739432 unsigned r=zc_oldrand();
10392
10393
4/4
✓ Branch 0 taken 11616 times.
✓ Branch 1 taken 727816 times.
✓ Branch 2 taken 839 times.
✓ Branch 3 taken 10777 times.
739432 if(!(r&63) && !HeroInRange(minRange))
10394 {
10395 10777 FireWeapon();
10396
10397
3/4
✓ Branch 0 taken 8406 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
10838 if(get_qr(qr_BROKENSTATUES)==0 &&
10398
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8345 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
8406 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10399 {
10400
2/2
✓ Branch 0 taken 7924 times.
✓ Branch 1 taken 482 times.
8406 if(!((r>>7)&15))
10401 {
10402 482 x-=4;
10403 482 FireWeapon();
10404 482 x+=4;
10405 482 }
10406 8406 }
10407
10408 10777 clk3=0;
10409 10777 }
10410 }
10411 739432 }
10412
10413 1551984 return enemy::animate(index);
10414 1551984 }
10415
10416 1557825 void eProjectile::draw(BITMAP *dest)
10417 {
10418 1557825 update_enemy_frame();
10419 1557825 enemy::draw(dest);
10420 1557825 }
10421
10422 180 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10423 180 {
10424 90 hxofs=1000;
10425 90 }
10426
10427 12175 void eTrigger::draw(BITMAP *dest)
10428 {
10429 12175 update_enemy_frame();
10430 12175 enemy::draw(dest);
10431 12175 }
10432
10433 void eTrigger::death_sfx()
10434 {
10435 //silent death
10436 }
10437
10438 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10439 {
10440 o_tile+=wpnsbuf[iwNPCs].tile;
10441 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10442 SIZEflags = d->SIZEflags;
10443 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10444 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10445 // al_trace("Enemy txsz:%i\n", txsz);
10446 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10447 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10448 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10449 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10450 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10451 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10452 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10453 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10454 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10455 {
10456 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10457 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10458 }
10459
10460 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10461 }
10462
10463 bool eNPC::animate(int32_t index)
10464 {
10465 if(switch_hooked) return enemy::animate(index);
10466 if(dying)
10467 return Dead(index);
10468
10469 if(clk==0)
10470 {
10471 removearmos(x,y,ffcactivated);
10472 }
10473
10474 switch(dmisc2)
10475 {
10476 case 0:
10477 {
10478 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10479 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10480
10481 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10482 {
10483 dir=down;
10484 }
10485
10486 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10487 {
10488 dir=right;
10489 }
10490 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10491 {
10492 dir=up;
10493 }
10494 else
10495 {
10496 dir=left;
10497 }
10498 }
10499 break;
10500
10501 case 1:
10502 halting_walk(rate, homing, 0, hrate, 48);
10503
10504 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10505 {
10506 newdir(rate, homing, 0);
10507 clk2=48;
10508 ++misc;
10509 }
10510
10511 if(clk2==0)
10512 misc=0;
10513
10514 break;
10515 }
10516
10517 return enemy::animate(index);
10518 }
10519
10520 void eNPC::draw(BITMAP *dest)
10521 {
10522 update_enemy_frame();
10523 enemy::draw(dest);
10524 }
10525
10526 int32_t eNPC::takehit(weapon*,weapon*)
10527 {
10528 return 0;
10529 }
10530
10531 188 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10532 188 {
10533
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10534 {
10535 94 o_tile=clk;
10536 94 cs=id>>12;
10537 94 }
10538
10539 94 id=id&0xFFF;
10540 94 clk=0;
10541
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10542 94 mainguy=false;
10543 94 SIZEflags = d->SIZEflags;
10544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10545 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10546 // al_trace("Enemy txsz:%i\n", txsz);
10547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10551
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10552
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10553 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10554
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10556 {
10557 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10558 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10559 }
10560
10561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10562 94 }
10563
10564 81 void eSpinTile::facehero()
10565 {
10566
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10567 {
10568
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10569 1 dir = up;
10570 else
10571 dir = down;
10572 1 }
10573 else
10574 {
10575 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10576 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10577
10578
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10579 {
10580 12 dir=l_down;
10581 12 }
10582
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10583 {
10584 1 dir=down;
10585 1 }
10586
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10587 {
10588 12 dir=r_down;
10589 12 }
10590
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10591 {
10592 6 dir=right;
10593 6 }
10594
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10595 {
10596 17 dir=r_up;
10597 17 }
10598
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10599 {
10600 8 dir=up;
10601 8 }
10602
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10603 {
10604 6 dir=l_up;
10605 6 }
10606 else
10607 {
10608 18 dir=left;
10609 }
10610 }
10611 81 }
10612
10613
10614 15539 bool eSpinTile::animate(int32_t index)
10615 {
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10617
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10618
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10619 {
10620 1152 return Dead(index);
10621 }
10622
10623
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10624 {
10625 1241 removearmos(x,y,ffcactivated);
10626 1241 }
10627
10628 14387 ++misc;
10629
10630
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10631 {
10632 81 facehero();
10633 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10634 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10635 81 angular=true;
10636 81 angle=ddir;
10637 81 step=zslongToFix(dstep*100);
10638 81 }
10639
10640
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10641 52 kickbucket();
10642
10643 14387 sprite::move(step);
10644 14387 return enemy::animate(index);
10645 15539 }
10646
10647 15457 void eSpinTile::draw(BITMAP *dest)
10648 {
10649 15457 update_enemy_frame();
10650 15457 y-=(misc>>4);
10651 15457 yofs+=2;
10652 15457 enemy::draw(dest);
10653 15457 yofs-=2;
10654 15457 y+=(misc>>4);
10655 15457 }
10656
10657 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10658 {
10659 15457 flip = 0;
10660 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10661 15457 yofs+=4;
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10663 15457 enemy::drawshadow(dest, translucent);
10664 15457 yofs-=4;
10665 15457 }
10666
10667 3210 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10668 3210 {
10669 //these are here to bypass compiler warnings about unused arguments
10670 1605 Clk=Clk;
10671 1605 mainguy=false;
10672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10673 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10674 {
10675 clk=1;
10676 }*/
10677 //nets+880;
10678 1605 SIZEflags = d->SIZEflags;
10679
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10680 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10681 // al_trace("Enemy txsz:%i\n", txsz);
10682
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10686
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10687
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10688 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10689
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10691 {
10692 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10693 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10694 }
10695
10696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10697 1605 }
10698
10699 392118 void eZora::facehero()
10700 {
10701
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 385554 times.
392118 if(Hero.x-x==0)
10702 {
10703 6564 dir=(Hero.y+8<y)?up:down;
10704 6564 }
10705 else
10706 {
10707 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10708 385554 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10709
10710
4/4
✓ Branch 0 taken 80572 times.
✓ Branch 1 taken 304982 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 49955 times.
385554 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10711 {
10712 49955 dir=l_down;
10713 49955 }
10714
4/4
✓ Branch 0 taken 57428 times.
✓ Branch 1 taken 278171 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 26811 times.
335599 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10715 {
10716 26811 dir=down;
10717 26811 }
10718
4/4
✓ Branch 0 taken 77619 times.
✓ Branch 1 taken 231169 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 47002 times.
308788 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10719 {
10720 47002 dir=r_down;
10721 47002 }
10722
4/4
✓ Branch 0 taken 102786 times.
✓ Branch 1 taken 159000 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 72169 times.
261786 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10723 {
10724 72169 dir=right;
10725 72169 }
10726
4/4
✓ Branch 0 taken 83714 times.
✓ Branch 1 taken 105903 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 53097 times.
189617 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10727 {
10728 53097 dir=r_up;
10729 53097 }
10730
4/4
✓ Branch 0 taken 54641 times.
✓ Branch 1 taken 81879 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 24024 times.
136520 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10731 {
10732 24024 dir=up;
10733 24024 }
10734
4/4
✓ Branch 0 taken 76377 times.
✓ Branch 1 taken 36119 times.
✓ Branch 2 taken 45760 times.
✓ Branch 3 taken 30617 times.
112496 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10735 {
10736 45760 dir=l_up;
10737 45760 }
10738 else
10739 {
10740 66736 dir=left;
10741 }
10742 }
10743 392118 }
10744
10745 554408 bool eZora::animate(int32_t index)
10746 {
10747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554408 times.
554408 if(switch_hooked) return enemy::animate(index);
10748
2/2
✓ Branch 0 taken 1868 times.
✓ Branch 1 taken 552540 times.
554408 if(dying)
10749 1868 return Dead(index);
10750
10751
2/2
✓ Branch 0 taken 548931 times.
✓ Branch 1 taken 3609 times.
552540 if(clk==0)
10752 {
10753 3609 removearmos(x,y,ffcactivated);
10754 3609 }
10755
10756
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 552509 times.
552540 if(watch)
10757 {
10758 31 ++clock_zoras[id];
10759 31 return true;
10760 }
10761
10762
2/2
✓ Branch 0 taken 160391 times.
✓ Branch 1 taken 392118 times.
552509 if(get_qr(qr_NEWENEMYTILES))
10763 {
10764 392118 facehero();
10765 392118 }
10766
10767
6/6
✓ Branch 0 taken 3333 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 2684 times.
✓ Branch 3 taken 537009 times.
✓ Branch 4 taken 4269 times.
✓ Branch 5 taken 2014 times.
552509 switch(clk)
10768 {
10769 case 0: // reposition him
10770 {
10771 4269 int32_t t=0;
10772 4269 int32_t pos2=zc_oldrand()%160 + 16;
10773 4269 bool placed=false;
10774
10775
4/4
✓ Branch 0 taken 4246 times.
✓ Branch 1 taken 20492 times.
✓ Branch 2 taken 12637 times.
✓ Branch 3 taken 3609 times.
24738 while(!placed && t<160)
10776 {
10777 12637 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10778
5/6
✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 8311 times.
✓ Branch 2 taken 4326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 3586 times.
16553 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4326 times.
4326 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10780
3/4
✓ Branch 0 taken 4326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3916 times.
✓ Branch 3 taken 3916 times.
4326 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10781 {
10782 3586 x=(pos2&15)<<4;
10783 3586 y=pos2&0xF0;
10784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3586 times.
3586 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10785 3586 hxofs=1000; // avoid hit detection
10786 3586 stunclk=0;
10787 3586 placed=true;
10788 3586 }
10789
10790 20469 pos2+=19;
10791
10792
2/2
✓ Branch 0 taken 18055 times.
✓ Branch 1 taken 2414 times.
20469 if(pos2>=176)
10793 2414 pos2-=160;
10794
10795 20469 ++t;
10796 }
10797
10798
3/4
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3586 times.
3609 if(!placed || whistleclk>=88) // can't place him, he's gone
10799 23 return true;
10800
10801 }
10802 3586 break;
10803
10804 case 35:
10805
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 965 times.
3333 if(!get_qr(qr_NEWENEMYTILES))
10806 {
10807 965 dir=(Hero.y+8<y)?up:down;
10808 965 }
10809
10810 3333 hxofs=0;
10811 3333 break;
10812
10813 case 35+19:
10814 3200 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10815 3200 sfx(wpnsfx(wpn),pan(int32_t(x)));
10816 3200 break;
10817
10818 case 35+66:
10819 2684 hxofs=1000;
10820 2684 break;
10821
10822 case 198:
10823 2014 clk=-1;
10824 2014 break;
10825 }
10826
10827 551826 return enemy::animate(index);
10828 553748 }
10829
10830 554283 void eZora::draw(BITMAP *dest)
10831 {
10832
2/2
✓ Branch 0 taken 10764 times.
✓ Branch 1 taken 543519 times.
554283 if(clk<3)
10833 10764 return;
10834
10835 543519 update_enemy_frame();
10836 543519 enemy::draw(dest);
10837 554283 }
10838
10839 bool eZora::isSubmerged() const
10840 {
10841 return ( clk < 3 );
10842 }
10843
10844
4/8
✓ Branch 0 taken 26759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26759 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26759 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26759 times.
✗ Branch 7 not taken.
80277 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10845 53518 {
10846 26759 multishot= timer = fired = dashing = 0;
10847 26759 hashero = false;
10848 26759 dummy_bool[0]=false;
10849 26759 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10850
5/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 26613 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 70 times.
26759 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10851 {
10852
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 step=zslongToFix(dmisc10*100);
10853
10854
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64 times.
76 if(anim==aARMOS4) o_tile+=20;
10855 76 }
10856
10857
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 26613 times.
26759 if(flags & guy_fadeflicker)
10858 {
10859 146 clk=0;
10860 146 superman = 1;
10861 146 fading=fade_flicker;
10862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10863 146 dir=down;
10864
10865
4/6
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 79 times.
146 if(!canmove(down,(zfix)8,spw_none,false))
10866
3/6
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
67 clk3=int32_t(13.0/step);
10867 146 }
10868
2/2
✓ Branch 0 taken 26612 times.
✓ Branch 1 taken 1 times.
26613 else if(flags & guy_fadeinstant)
10869 {
10870 1 clk=0;
10871 1 }
10872
10873
1/2
✓ Branch 0 taken 26759 times.
✗ Branch 1 not taken.
26759 shadowdistance = 0;
10874 26759 clk4 = clk5 = 0;
10875 //nets+2380;
10876 26759 SIZEflags = d->SIZEflags;
10877
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26759 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10878 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10879 // al_trace("Enemy txsz:%i\n", txsz);
10880
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26759 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26759 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26759 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26759 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10884
1/2
✓ Branch 0 taken 26759 times.
✗ Branch 1 not taken.
26759 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10885
1/2
✓ Branch 0 taken 26759 times.
✗ Branch 1 not taken.
26759 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10886 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26759 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
26759 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10889 {
10890 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10891 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10892 }
10893
10894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26759 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10895 26759 }
10896
10897 9628745 bool eStalfos::animate(int32_t index)
10898 {
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9628745 times.
9628745 if(switch_hooked) return enemy::animate(index);
10900
3/4
✓ Branch 0 taken 9628603 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9628603 times.
9628745 if(fallclk||drownclk)
10901 {
10902 142 return enemy::animate(index);
10903 }
10904
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 9420704 times.
9628603 if(dying)
10905 {
10906
2/2
✓ Branch 0 taken 207868 times.
✓ Branch 1 taken 31 times.
207899 if(hashero)
10907 {
10908 31 Hero.setEaten(0);
10909 31 hashero=false;
10910 31 }
10911
10912
10/14
✓ Branch 0 taken 20374 times.
✓ Branch 1 taken 187525 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 19234 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
207899 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10913 {
10914 49 hp=-1000;
10915
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10916 49 Ewpns.add(ew);
10917 49 ew->fakez = fakez;
10918
10919
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
10920 {
10921 49 ew->step=0;
10922 49 ew->id=wpn;
10923 49 ew->misc=50;
10924 49 ew->clk=48;
10925 49 }
10926
10927 49 fired=true;
10928 49 }
10929
6/6
✓ Branch 0 taken 95092 times.
✓ Branch 1 taken 112758 times.
✓ Branch 2 taken 77556 times.
✓ Branch 3 taken 17536 times.
✓ Branch 4 taken 77538 times.
✓ Branch 5 taken 18 times.
207850 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10930 {
10931
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10932 {
10933 1 int32_t wpn2 = wpn+dmisc3;
10934
10935
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10936 {
10937 wpn2=wpn;
10938 }
10939
10940 1 dummy_bool[0]=true;
10941 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10942 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10943 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10944 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10945 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10946 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10947 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10948 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10949 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10950 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10951 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10952 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10953 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10954 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10955 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10956 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10957 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10958 1 }
10959 18 }
10960
10961 207899 KillWeapon();
10962 207899 return Dead(index);
10963 }
10964 //vire split
10965 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10966 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10967
13/14
✓ Branch 0 taken 11844 times.
✓ Branch 1 taken 9408860 times.
✓ Branch 2 taken 11844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 11695 times.
✓ Branch 6 taken 819531 times.
✓ Branch 7 taken 8601024 times.
✓ Branch 8 taken 818273 times.
✓ Branch 9 taken 1258 times.
✓ Branch 10 taken 4401 times.
✓ Branch 11 taken 813872 times.
✓ Branch 12 taken 803 times.
✓ Branch 13 taken 3598 times.
9420704 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10968 {
10969 952 stop_bgsfx(index);
10970 952 int32_t kids = guys.Count();
10971 952 int32_t id2=dmisc3;
10972
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 952 times.
2842 for(int32_t i=0; i < dmisc4; i++)
10973 {
10974 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10975
4/6
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1890 times.
1890 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10976 1890 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10977 1890 }
10978
10979
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(itemguy) // Hand down the carried item
10980 {
10981 guycarryingitem = guys.Count()-1;
10982 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10983 itemguy = false;
10984 }
10985
10986
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(hashero)
10987 {
10988 Hero.setEaten(0);
10989 hashero=false;
10990 }
10991
10992
4/4
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 803 times.
✓ Branch 3 taken 135 times.
952 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10993 135 sfx(deadsfx,pan(int32_t(x)));
10994
10995 952 return true;
10996 }
10997 /*
10998 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10999 {
11000 stop_bgsfx(index);
11001 int32_t kids = guys.Count();
11002 int32_t id2=dmisc3;
11003
11004 for(int32_t i=0; i < dmisc4; i++)
11005 {
11006 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
11007 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
11008 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11009 }
11010
11011 if(itemguy) // Hand down the carried item
11012 {
11013 guycarryingitem = guys.Count()-1;
11014 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11015 itemguy = false;
11016 }
11017
11018 if(hashero)
11019 {
11020 Hero.setEaten(0);
11021 hashero=false;
11022 }
11023
11024 return true;
11025 }
11026 */
11027
2/2
✓ Branch 0 taken 12473 times.
✓ Branch 1 taken 9407279 times.
9419752 if(fading)
11028 {
11029
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 12264 times.
12473 if(++clk4 > 60)
11030 {
11031 209 clk4=0;
11032 209 superman=0;
11033 209 fading=0;
11034
11035
4/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
209 if(flags2&cmbflag_armos && z==0 && fakez == 0)
11036 {
11037 //if a custom size (not 16px by 16px)
11038
11039 //if a custom size (not 16px by 16px)
11040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (ffcactivated)
11041 removearmosffc(ffcactivated-1);
11042 else
11043 {
11044
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11045 {
11046 //zprint("spawn big enemy from armos\n");
11047 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11048 for(int32_t dx = 0; dx < tysz; dx ++)
11049 {
11050 for(int32_t dy = 0; dy < tysz; dy++)
11051 {
11052 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
11053 did_armos = false;
11054 }
11055 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
11056 did_armos = false;
11057 }
11058 for(int32_t dy = 0; dy < tysz; dy ++)
11059 {
11060 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
11061 did_armos = false;
11062 }
11063 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
11064 }
11065 146 else removearmos(x,y);
11066 }
11067 /*
11068 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11069 {
11070 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11071 for(int32_t dx = 0; dx < hxsz; dx += 16)
11072 {
11073 for(int32_t dy = 0; dy < hysz; dy += 16)
11074 {
11075 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
11076 did_armos = false;
11077 }
11078 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11079 did_armos = false;
11080 }
11081 for(int32_t dy = 0; dy < hysz; dy += 16)
11082 {
11083 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
11084 did_armos = false;
11085 }
11086 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11087 }
11088 else removearmos(x,y,ffcactivated);
11089 */
11090
11091 146 }
11092
11093 209 clk2=0;
11094
11095 209 newdir();
11096 209 }
11097 12264 else return enemy::animate(index);
11098 209 }
11099
6/8
✓ Branch 0 taken 31933 times.
✓ Branch 1 taken 9375346 times.
✓ Branch 2 taken 31933 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31933 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29901 times.
✓ Branch 7 taken 2032 times.
9407279 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
11100 2032 removearmos(x,y,ffcactivated);
11101
11102
11103
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 9404948 times.
9407488 if(hashero)
11104 {
11105 2540 Hero.setX(x);
11106 2540 Hero.setY(y);
11107 2540 ++clk2;
11108
11109
4/4
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2489 times.
✓ Branch 3 taken 51 times.
2540 if(clk2==(dmisc8==0 ? 95 : dmisc8))
11110 {
11111
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
11112 {
11113 case e7tEATITEMS:
11114 {
11115
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
11116 {
11117
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
11118 1 game->set_item(i, false);
11119 256 }
11120
11121 1 break;
11122 }
11123
11124 case e7tEATMAGIC:
11125 game->change_dmagic(-1*game->get_magicdrainrate());
11126 break;
11127
11128 case e7tEATRUPEES:
11129 game->change_drupy(-1);
11130 break;
11131 }
11132
11133 51 clk2=0;
11134 51 }
11135
11136
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2335 times.
2540 if((clk&0x18)==8) // stop its animation on the middle frame
11137 2335 --clk;
11138 2540 }
11139
4/4
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8704834 times.
✓ Branch 2 taken 408221 times.
✓ Branch 3 taken 291893 times.
9404948 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
11140 {
11141 // Movement engine
11142
4/6
✓ Branch 0 taken 504520 times.
✓ Branch 1 taken 8608535 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8606203 times.
✗ Branch 5 not taken.
9113055 if(clk>=0) switch(id>>12)
11143 {
11144 case 0: // Normal movement
11145
11146 /*
11147 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
11148 {
11149 // Overloading clk4 (Tribble clock) here...
11150 step=17/100.0;
11151 if(clk4<32) misc=1;
11152 else if(clk4<48) misc=2;
11153 else if(clk4<300) { misc=3; step = dstep/100.0; }
11154 else if(clk4<316) misc=2;
11155 else if(clk4<412) misc=1;
11156 else if(clk4<540) { misc=0; step=0; }
11157 else clk4=0;
11158 if(clk4==48) clk=0;
11159 hxofs=(misc>=2)?0:1000;
11160 if (dmisc9==e9tLEEVER)
11161 variable_walk(rate, homing, 0);
11162 else
11163 variable_walk_8(rate, homing, 4, 0);
11164 break;
11165 }
11166 */
11167
4/4
✓ Branch 0 taken 8407145 times.
✓ Branch 1 taken 199058 times.
✓ Branch 2 taken 273002 times.
✓ Branch 3 taken 8134143 times.
8606203 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
11168 {
11169 472060 vire_hop();
11170 472060 break;
11171 }
11172
2/2
✓ Branch 0 taken 649572 times.
✓ Branch 1 taken 7484571 times.
8134143 else if(dmisc9==e9tROPE) //Rope charge
11173 {
11174
9/10
✓ Branch 0 taken 632150 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 89355 times.
✓ Branch 3 taken 542795 times.
✓ Branch 4 taken 80424 times.
✓ Branch 5 taken 8931 times.
✓ Branch 6 taken 79638 times.
✓ Branch 7 taken 786 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79638 times.
649572 if(!fired && dashing && !stunclk && !watch && !frozenclock)
11175 {
11176
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 77266 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
79638 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
11177 {
11178
11179
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
11180 {
11181 14 hp=-1000;
11182
11183
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11184 {
11185
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
11186 14 Ewpns.add(ew);
11187 14 ew->fakez = fakez;
11188
11189
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
11190 {
11191 14 ew->step=0;
11192 14 ew->id=wpn+dmisc3;
11193 14 ew->misc=50;
11194 14 ew->clk=48;
11195 14 }
11196
11197 14 fired=true;
11198 14 }
11199 else
11200 {
11201 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
11202 Ewpns.add(ew);
11203 ew->fakez = fakez;
11204
11205 if(wpn==ewSBomb || wpn==ewBomb)
11206 {
11207 ew->step=0;
11208 ew->id=wpn;
11209 ew->misc=50;
11210 ew->clk=48;
11211 }
11212
11213 fired=true;
11214 }
11215 14 }
11216
11217 else
11218 {
11219 1 hp=-1000;
11220
11221 int32_t wpn2;
11222
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11223 1 wpn2=wpn;
11224 else
11225 wpn2=wpn;
11226
11227
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
11228 1 Ewpns.add(ew);
11229 1 ew->fakez = fakez;
11230
11231
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
11232 {
11233 1 ew->step=0;
11234 1 ew->id=wpn2;
11235 1 ew->misc=50;
11236 1 ew->clk=48;
11237 1 }
11238
11239 1 fired=true;
11240 }
11241 15 }
11242 79638 }
11243
11244 649572 charge_attack();
11245 649572 break;
11246 }
11247 /*
11248 * Boomerang-throwers have a halt count of 1
11249 * Zols have a halt count of (zc_oldrand()&7)<<4
11250 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11251 * Everything else has 48
11252 */
11253 else
11254 {
11255
2/2
✓ Branch 0 taken 378407 times.
✓ Branch 1 taken 7106164 times.
7484571 if(wpn==ewBrang) // Goriya
11256 {
11257 378407 halting_walk(rate,homing,0,hrate, 1);
11258 378407 }
11259
4/4
✓ Branch 0 taken 7074085 times.
✓ Branch 1 taken 32079 times.
✓ Branch 2 taken 2912329 times.
✓ Branch 3 taken 4161756 times.
7106164 else if(dmisc9==e9tNORMAL && wpn==0)
11260 {
11261
2/2
✓ Branch 0 taken 574887 times.
✓ Branch 1 taken 3586869 times.
4161756 if(dmisc2==e2tSPLITHIT) // Zol
11262 {
11263 574887 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11264 574887 }
11265
4/4
✓ Branch 0 taken 1147347 times.
✓ Branch 1 taken 2439522 times.
✓ Branch 2 taken 1047903 times.
✓ Branch 3 taken 99444 times.
3586869 else if(frate<=8 && starting_hp==1) // Gel
11266 {
11267 99444 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11268 99444 }
11269 else // Other
11270 {
11271 3487425 halting_walk(rate,homing,0,hrate, 48);
11272 }
11273 4161756 }
11274 else // Other
11275 {
11276 2944408 halting_walk(rate,homing,0,hrate, 48);
11277 }
11278 }
11279
11280 //if not in midair, and Hero's swinging sword is nearby, jump.
11281 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11282 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11283 {
11284 facehero(false);
11285 sclk=16+((dir^1)<<8);
11286 fall=-FEATHERJUMP;
11287 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11288 }*/
11289 7484571 break;
11290
11291 // Following cases are for just after creation-by-splitting.
11292 case 1:
11293
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 580 times.
2332 if(misc==1)
11294 {
11295 580 dir=up;
11296 580 step=8;
11297 580 }
11298
11299
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 1773 times.
2332 if(misc<=2)
11300 {
11301 1773 move(step);
11302
11303
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 343 times.
1773 if(!canmove(dir,(zfix)0,0,false))
11304 343 dir=down;
11305 1773 }
11306
11307
2/2
✓ Branch 0 taken 1773 times.
✓ Branch 1 taken 559 times.
2332 if(misc==3)
11308 {
11309
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 350 times.
559 if(canmove(right,(zfix)16,0,false))
11310 350 x+=16;
11311 559 }
11312
11313 2332 ++misc;
11314 2332 break;
11315
11316 case 2:
11317 if(misc==1)
11318 {
11319 dir=down;
11320 step=8;
11321 }
11322
11323 if(misc<=2)
11324 {
11325 move(step);
11326 /*
11327 if(!canmove(dir,(zfix)0,0,false))
11328 dir=up;
11329 */
11330 }
11331
11332 if(misc==3)
11333 {
11334 if(canmove(left,(zfix)16,0,false))
11335 x-=16;
11336 }
11337
11338 ++misc;
11339 break;
11340
11341 default:
11342 if(misc==1)
11343 {
11344 dir=(zc_oldrand()%4);
11345 step=8;
11346 }
11347
11348 if(misc<=2)
11349 {
11350 move(step);
11351
11352 if(!canmove(dir,(zfix)0,0,false))
11353 dir=dir^1;
11354 }
11355
11356 if(misc==3)
11357 {
11358 if(dir >= left && canmove(dir,(zfix)16,0,false))
11359 x+=(dir==left ? -16 : 16);
11360 }
11361
11362 ++misc;
11363 break;
11364 8608535 }
11365
11366
4/4
✓ Branch 0 taken 16816 times.
✓ Branch 1 taken 9096239 times.
✓ Branch 2 taken 16257 times.
✓ Branch 3 taken 559 times.
9113055 if(id>>12 && misc>=4) //recently spawned by a split enemy
11367 {
11368 559 id&=0xFFF;
11369 559 step = zslongToFix(dstep*100);
11370
11371
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 if(x<32) x=32;
11372
11373
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 13 times.
559 if(x>208) x=208;
11374
11375
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 18 times.
559 if(y<32) y=32;
11376
11377
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 5 times.
559 if(y>128) y=128;
11378
11379 559 misc=3;
11380 559 }
11381 9113055 }
11382 else
11383 {
11384 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11385
1/2
✓ Branch 0 taken 291893 times.
✗ Branch 1 not taken.
291893 if(clk2>2) clk2--;
11386 }
11387
11388 // Fire Zol
11389
7/8
✓ Branch 0 taken 3944791 times.
✓ Branch 1 taken 5462697 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3938157 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
9407488 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11390 {
11391 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11392 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
11393
11394 47 int32_t i=Ewpns.Count()-1;
11395 47 weapon *ew = (weapon*)(Ewpns.spr(i));
11396
11397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11398 {
11399 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11400 if ( ew->do_animation ) ew->tile+=ew->aframe;
11401 }
11402 47 }
11403 // Goriya
11404
14/16
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8707327 times.
✓ Branch 2 taken 318261 times.
✓ Branch 3 taken 381853 times.
✓ Branch 4 taken 310952 times.
✓ Branch 5 taken 7309 times.
✓ Branch 6 taken 286403 times.
✓ Branch 7 taken 24549 times.
✓ Branch 8 taken 286403 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283662 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 283662 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 279458 times.
✓ Branch 15 taken 4204 times.
9407441 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11405 {
11406 4204 misc=index+100;
11407
7/14
✓ Branch 0 taken 4204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4204 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4204 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4204 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4204 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4204 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4204 times.
✗ Branch 13 not taken.
4204 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11408 4204 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11409
11410
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 155 times.
4204 if(dmisc1==2)
11411 {
11412 155 int32_t ndir=dir;
11413
11414
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
11415 {
11416 4 ndir=(Hero.y+8<y)?up:down;
11417 4 }
11418 else //turn to face Hero
11419 {
11420 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11421 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11422
11423
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11424 {
11425 9 ndir=down;
11426 9 }
11427
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11428 {
11429 41 ndir=right;
11430 41 }
11431
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11432 {
11433 33 ndir=up;
11434 33 }
11435 else
11436 {
11437 68 ndir=left;
11438 }
11439 }
11440
11441 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11442
11443
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
11444 {
11445 153 dir=ndir;
11446 153 }
11447 155 }
11448 4204 }
11449
15/16
✓ Branch 0 taken 9366374 times.
✓ Branch 1 taken 36863 times.
✓ Branch 2 taken 121574 times.
✓ Branch 3 taken 9281663 times.
✓ Branch 4 taken 106507 times.
✓ Branch 5 taken 15067 times.
✓ Branch 6 taken 91800 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 91114 times.
✓ Branch 9 taken 686 times.
✓ Branch 10 taken 82969 times.
✓ Branch 11 taken 8145 times.
✓ Branch 12 taken 82969 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 82025 times.
9403237 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11450
3/3
✓ Branch 0 taken 16959 times.
✓ Branch 1 taken 64165 times.
✓ Branch 2 taken 901 times.
82025 switch(dmisc1)
11451 {
11452 case e1tCONSTANT: //Deathnut
11453 {
11454 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11455
2/2
✓ Branch 0 taken 62822 times.
✓ Branch 1 taken 1343 times.
64165 if(clk5>64)
11456 {
11457 1343 clk5=0;
11458 1343 fired=false;
11459 1343 }
11460
11461 64165 clk5+=(zc_oldrand()&3);
11462
11463
4/4
✓ Branch 0 taken 39489 times.
✓ Branch 1 taken 24676 times.
✓ Branch 2 taken 13354 times.
✓ Branch 3 taken 26135 times.
64165 if((clk5>24)&&(clk5<52))
11464 {
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26135 times.
26135 if ( do_animation )tile+=20; //firing
11466
11467
4/4
✓ Branch 0 taken 14252 times.
✓ Branch 1 taken 11883 times.
✓ Branch 2 taken 12803 times.
✓ Branch 3 taken 1449 times.
26135 if(!fired&&(clk5>=38))
11468 {
11469
5/10
✓ Branch 0 taken 1449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1449 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1449 times.
✗ Branch 9 not taken.
1449 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11470 1449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11471 1449 sfx(wpnsfx(wpn),pan(int32_t(x)));
11472 1449 fired=true;
11473 1449 }
11474 26135 }
11475
11476 64165 break;
11477 }
11478
11479 case e1tFIREOCTO: //Fire Octo
11480 901 timer=zc_oldrand()%50+50;
11481 901 break;
11482
11483 default:
11484 16959 FireWeapon();
11485 16959 break;
11486 82025 }
11487
11488 /* Fire again if:
11489 * - clk2 about to run out
11490 * - not already double-firing (dmisc1 is 1)
11491 * - not carrying Hero
11492 * - one in 0xF chance
11493 */
11494
8/10
✓ Branch 0 taken 352788 times.
✓ Branch 1 taken 9054700 times.
✓ Branch 2 taken 3024 times.
✓ Branch 3 taken 349764 times.
✓ Branch 4 taken 3024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2830 times.
✓ Branch 9 taken 194 times.
9407488 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11495 {
11496 #if 1
11497 194 newdir(rate, homing, grumble);
11498 #else
11499 dir^=2;
11500 #endif
11501 194 clk2=28;
11502 194 ++multishot;
11503 194 }
11504
11505
2/2
✓ Branch 0 taken 2280564 times.
✓ Branch 1 taken 7126924 times.
9407488 if(clk2==0)
11506 {
11507 7126924 multishot = 0;
11508 7126924 }
11509
11510
2/2
✓ Branch 0 taken 9343371 times.
✓ Branch 1 taken 64117 times.
9407488 if(timer) //Fire Octo
11511 {
11512 64117 clk2=15; //this keeps the octo in place until he's done firing
11513
11514
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
11515 {
11516 15704 FireBreath(false);
11517 15704 }
11518
11519 64117 --timer;
11520 64117 }
11521
11522
2/2
✓ Branch 0 taken 9230659 times.
✓ Branch 1 taken 176829 times.
9407488 if(dmisc2==e2tTRIBBLE)
11523 176829 ++clk4;
11524
11525
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 9405248 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 9406881 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
9407488 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11526 {
11527 607 int32_t kids = guys.Count();
11528 607 int32_t id2=dmisc3;
11529
11530
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 607 times.
1214 for(int32_t i=0; i<dmisc4; i++)
11531 {
11532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
607 if(addenemy(x,y,id2,-24))
11533 {
11534
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(itemguy) // Hand down the carried item
11535 {
11536 guycarryingitem = guys.Count()-1;
11537 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11538 itemguy = false;
11539 }
11540
11541 607 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11542 607 }
11543 607 }
11544
11545
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(hashero)
11546 {
11547 Hero.setEaten(0);
11548 hashero=false;
11549 }
11550
11551 607 stop_bgsfx(index);
11552 607 return true;
11553 }
11554
11555 9406881 return enemy::animate(index);
11556 9628745 }
11557
11558 9949199 void eStalfos::draw(BITMAP *dest)
11559 {
11560 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11561 {
11562 clk4--; //Kludge
11563 return;
11564 }*/
11565
11566 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11567 {
11568 cs = dcset;
11569 }*/
11570 9949199 update_enemy_frame();
11571
11572
7/8
✓ Branch 0 taken 9949057 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 9949057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 9913082 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
9949199 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11573 {
11574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
11575 2890 }
11576
11577 9949199 enemy::draw(dest);
11578 9949199 }
11579
11580 2684062 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11581 {
11582 2684062 int32_t tempy=yofs;
11583
11584 /*
11585 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11586 flip = 0;
11587 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11588 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11589 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11590 yofs+=(((int32_t)y+17)&0xF0)-y;
11591 yofs+=8;
11592 }
11593 */
11594
4/4
✓ Branch 0 taken 2598921 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2664930 times.
✓ Branch 3 taken 19132 times.
2684062 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11595 {
11596 19132 flip = 0;
11597 19132 int32_t fdiv = frate/4;
11598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19132 times.
19132 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11599
11600
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11601 19132 efrate:((clk>=(frate>>1))?1:0);
11602 19132 shadowtile = wpnsbuf[spr_shadow].tile;
11603
11604
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 if(get_qr(qr_NEWENEMYTILES))
11605 {
11606 19132 shadowtile+=f2;
11607 19132 }
11608 else
11609 {
11610 shadowtile+=f2?1:0;
11611 }
11612
11613 19132 yofs+=shadowdistance;
11614 19132 yofs+=8;
11615 19132 }
11616
3/4
✓ Branch 0 taken 2598921 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2684062 times.
✗ Branch 3 not taken.
2684062 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11617 {
11618 flip = 0;
11619 int32_t fdiv = frate/4;
11620 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11621
11622 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11623 efrate:((clk>=(frate>>1))?1:0);
11624 shadowtile = wpnsbuf[spr_shadow].tile;
11625
11626 if(get_qr(qr_NEWENEMYTILES))
11627 {
11628 shadowtile+=f2;
11629 }
11630 else
11631 {
11632 shadowtile+=f2?1:0;
11633 }
11634 }
11635
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 2683920 times.
2684062 if(!shadow_overpit(this))
11636 2683920 enemy::drawshadow(dest, translucent);
11637 2684062 yofs=tempy;
11638 2684062 }
11639
11640 98900 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11641 {
11642 98900 int32_t wpnId = w->id;
11643 98900 int32_t wpnDir = w->dir;
11644
11645
4/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 98324 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 380 times.
98900 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11646
5/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 77 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 77 times.
196 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
11647
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
11648 {
11649 119 shield = false;
11650 119 flags &= ~(inv_left|inv_right|inv_back|inv_front);
11651
11652
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 14 times.
119 if(get_qr(qr_BRKNSHLDTILES))
11653 14 o_tile=s_tile;
11654 119 }
11655
11656 98900 int32_t ret = enemy::takehit(w,realweap);
11657
11658
4/4
✓ Branch 0 taken 12005 times.
✓ Branch 1 taken 86895 times.
✓ Branch 2 taken 10754 times.
✓ Branch 3 taken 1251 times.
98900 if(sclk && dmisc2==e2tSPLITHIT)
11659 1251 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11660
11661 98900 return ret;
11662 }
11663
11664 649572 void eStalfos::charge_attack()
11665 {
11666
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 644651 times.
649572 if(slide())
11667 4921 return;
11668
11669
9/12
✓ Branch 0 taken 644651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 644651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 622871 times.
✓ Branch 5 taken 21780 times.
✓ Branch 6 taken 604111 times.
✓ Branch 7 taken 18760 times.
✓ Branch 8 taken 599945 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 599945 times.
644651 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11670 44706 return;
11671
11672
2/2
✓ Branch 0 taken 23890 times.
✓ Branch 1 taken 576055 times.
599945 if(clk3<=0)
11673 {
11674 23890 fix_coords(true);
11675
11676
2/2
✓ Branch 0 taken 6397 times.
✓ Branch 1 taken 17493 times.
23890 if(!dashing)
11677 {
11678 17493 int32_t ldir = lined_up(7,false);
11679
11680
4/4
✓ Branch 0 taken 1774 times.
✓ Branch 1 taken 15719 times.
✓ Branch 2 taken 1497 times.
✓ Branch 3 taken 277 times.
17493 if(ldir!=-1 && canmove(ldir,false))
11681 {
11682 1497 dir=ldir;
11683 1497 dashing=true;
11684 1497 step=zslongToFix(dstep*100)+1;
11685 1497 }
11686 15996 else newdir(4,0,0);
11687 17493 }
11688
11689
2/2
✓ Branch 0 taken 23007 times.
✓ Branch 1 taken 883 times.
23890 if(!canmove(dir,false))
11690 {
11691 883 step=zslongToFix(dstep*100);
11692 883 newdir();
11693 883 dashing=false;
11694 883 }
11695
11696 23890 zfix div = step;
11697
11698
1/2
✓ Branch 0 taken 23890 times.
✗ Branch 1 not taken.
23890 if(div == 0)
11699 div = 1;
11700
11701 23890 clk3=(int32_t)(16.0/div);
11702 23890 return;
11703 }
11704
11705 576055 move(step);
11706 576055 --clk3;
11707 649572 }
11708
11709 472060 void eStalfos::vire_hop()
11710 {
11711 //if ( sclk > 0 ) return; //Don't hop during knockback.
11712
11713 // if(dmisc9!=e9tPOLSVOICE)
11714 // {
11715 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11716 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11717 // return; //the enemy should split if it is sliding!
11718 // //else sclk=0; //might need this here, too. -Z
11719 // }
11720
2/2
✓ Branch 0 taken 199058 times.
✓ Branch 1 taken 273002 times.
472060 if(dmisc9!=e9tPOLSVOICE)
11721 {
11722
2/2
✓ Branch 0 taken 193681 times.
✓ Branch 1 taken 5377 times.
199058 if(sclk!=0)
11723 {
11724
2/2
✓ Branch 0 taken 1534 times.
✓ Branch 1 taken 3843 times.
5377 if (dmisc2==e2tSPLITHIT) return;
11725 //return;
11726 3843 }
11727 197524 }
11728 273002 else sclk=0;
11729
11730
8/12
✓ Branch 0 taken 470526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 462011 times.
✓ Branch 5 taken 8515 times.
✓ Branch 6 taken 446955 times.
✓ Branch 7 taken 15056 times.
✓ Branch 8 taken 446955 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 446955 times.
470526 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11731 23571 return;
11732
11733 446955 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11734 446955 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11735
11736 446955 y=floor_y;
11737
11738
2/2
✓ Branch 0 taken 432185 times.
✓ Branch 1 taken 14770 times.
446955 if(clk3<=0)
11739 {
11740 14770 fix_coords();
11741
11742 //z=0;
11743 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11744 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11745
9/10
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
✓ Branch 2 taken 2542 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2448 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
14770 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
11746 12322 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11747
11748
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
14770 if(clk2<=0)
11749 {
11750 //z=0;
11751
6/6
✓ Branch 0 taken 10893 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 10646 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 7845 times.
✓ Branch 5 taken 2801 times.
11899 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11752 {
11753
11754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9098 times.
9098 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11755 /*if (dmisc9==e9tPOLSVOICE )
11756 {
11757 zprint2("polsvoice jump_width is: %d\n", jump_width);
11758 zprint2("polsvoice raw step is: %d\n", step);
11759 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11760 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11761 }
11762 else
11763 {
11764 zprint2("vire jump_width is: %d\n", jump_width);
11765 zprint2("vire raw step is: %d\n", step);
11766 zprint2("vire step.getInt() is: %d\n", step.getInt());
11767 zprint2("setting clk2 on vire to: %d\n", clk2);
11768 }
11769 */
11770 9098 }
11771 11899 }
11772
11773
4/4
✓ Branch 0 taken 6207 times.
✓ Branch 1 taken 8563 times.
✓ Branch 2 taken 2801 times.
✓ Branch 3 taken 3406 times.
14770 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11774 {
11775 3406 clk2=int32_t((16.0*jump_width)/step.getFloat());
11776 3406 }
11777
11778 14770 clk3=int32_t(16.0/step.getFloat());
11779 14770 }
11780
11781 446955 --clk3;
11782
11783
3/4
✓ Branch 0 taken 185954 times.
✓ Branch 1 taken 261001 times.
✓ Branch 2 taken 185954 times.
✗ Branch 3 not taken.
446955 if(dmisc9==e9tPOLSVOICE || clk2>0)
11784 446955 move(step);
11785
11786 446955 floor_y=y;
11787 446955 clk2--;
11788
11789 //if we're in the middle of a jump
11790
6/6
✓ Branch 0 taken 350625 times.
✓ Branch 1 taken 96330 times.
✓ Branch 2 taken 148718 times.
✓ Branch 3 taken 201907 times.
✓ Branch 4 taken 67317 times.
✓ Branch 5 taken 81401 times.
446955 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11791 {
11792 269224 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11793
11794
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 172140 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
269224 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11795 {
11796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
11797 90933 else z=h;
11798 90933 }
11799 else
11800 {
11801 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11802 //y-=h;
11803 178291 y=floor_y-h;
11804 178291 shadowdistance=h;
11805 }
11806 269224 }
11807 else
11808 177731 shadowdistance = 0;
11809 472060 }
11810
11811 51 void eStalfos::eathero()
11812 {
11813
5/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 32 times.
51 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11814 {
11815 32 hashero=true;
11816 32 y=floor_y;
11817 32 z=0;
11818
11819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(Hero.isSwimming())
11820 {
11821 Hero.setX(x);
11822 Hero.setY(y);
11823 }
11824 else
11825 {
11826 32 x=Hero.getX();
11827 32 y=Hero.getY();
11828 }
11829
11830 32 clk2=0;
11831 32 }
11832 51 }
11833
11834 983776 bool eStalfos::WeaponOut()
11835 {
11836
2/2
✓ Branch 0 taken 1749223 times.
✓ Branch 1 taken 412425 times.
2161648 for(int32_t i=0; i<Ewpns.Count(); i++)
11837 {
11838
3/4
✓ Branch 0 taken 571351 times.
✓ Branch 1 taken 1177872 times.
✓ Branch 2 taken 571351 times.
✗ Branch 3 not taken.
1749223 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11839 {
11840 571351 return true;
11841 }
11842
11843 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11844 stop_sfx(bgsfx);
11845 */
11846 1177872 }
11847
11848 412425 return false;
11849 983776 }
11850
11851 207899 void eStalfos::KillWeapon()
11852 {
11853
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 188444 times.
396343 for(int32_t i=0; i<Ewpns.Count(); i++)
11854 {
11855
4/4
✓ Branch 0 taken 159094 times.
✓ Branch 1 taken 29350 times.
✓ Branch 2 taken 158567 times.
✓ Branch 3 taken 527 times.
188444 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11856 {
11857 //only kill this Goriya's boomerang -DD
11858
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 234 times.
527 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11859 {
11860 234 Ewpns.del(i);
11861 234 }
11862 527 }
11863 188444 }
11864
11865
4/4
✓ Branch 0 taken 17536 times.
✓ Branch 1 taken 190363 times.
✓ Branch 2 taken 8819 times.
✓ Branch 3 taken 8717 times.
207899 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11866 {
11867 8819 stop_sfx(WAV_BRANG);
11868 8819 }
11869 207899 }
11870
11871 void eStalfos::break_shield()
11872 {
11873 if(!shield)
11874 return;
11875
11876 flags&=~(inv_front | inv_back | inv_left | inv_right);
11877 shield=false;
11878
11879 if(get_qr(qr_BRKNSHLDTILES))
11880 o_tile=s_tile;
11881 }
11882
11883 13242 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11884 13242 {
11885
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 dir=(zc_oldrand()&7)+8;
11886
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 step=0;
11887 6621 movestatus=1;
11888
3/4
✓ Branch 0 taken 5596 times.
✓ Branch 1 taken 1025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5596 times.
6621 if (dmisc1 != 1 && dmisc19 > 0)
11889 {
11890 step = dmisc19/100.0;
11891 movestatus = 1;
11892 }
11893
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if (dmisc1 == 2) movestatus=2;
11894 6621 c=0;
11895 6621 SIZEflags = d->SIZEflags;
11896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
11897
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11898
11899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12;
11900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
11901
11902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
11903
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11904
11905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8;
11906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
11907
11908
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11909 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
11910 // al_trace("Enemy txsz:%i\n", txsz);
11911
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11912
11913
11914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
11915
11916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11918 {
11919 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11920 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11921 }
11922
11923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11924 6621 clk4=0;
11925 //nets;
11926 6621 dummy_int[1]=0;
11927 6621 }
11928
11929 1835461 bool eKeese::animate(int32_t index)
11930 {
11931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835461 times.
1835461 if(switch_hooked) return enemy::animate(index);
11932
2/4
✓ Branch 0 taken 1835461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1835461 times.
1835461 if(fallclk||drownclk) return enemy::animate(index);
11933
2/2
✓ Branch 0 taken 68910 times.
✓ Branch 1 taken 1766551 times.
1835461 if(dying)
11934 68910 return Dead(index);
11935
11936
2/2
✓ Branch 0 taken 15740 times.
✓ Branch 1 taken 1750811 times.
1766551 if(clk==0)
11937 {
11938 15740 removearmos(x,y,ffcactivated);
11939 15740 }
11940
11941
2/2
✓ Branch 0 taken 382128 times.
✓ Branch 1 taken 1384423 times.
1766551 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11942 {
11943 382128 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11944 382128 }
11945 else
11946 {
11947
1/2
✓ Branch 0 taken 1384423 times.
✗ Branch 1 not taken.
1384423 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11948 1384423 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11949 }
11950
11951
2/2
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 1730770 times.
1766551 if(dmisc2 == e2tKEESETRIB)
11952 {
11953
3/4
✓ Branch 0 taken 35781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35710 times.
✓ Branch 3 taken 71 times.
35781 if(++clk4==(dmisc20>0?dmisc20:256))
11954 {
11955
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 53 times.
71 if(!m_walkflag(x,y,0, dir))
11956 {
11957 53 int32_t kids = guys.Count();
11958 53 bool success = false;
11959 53 int32_t id2=dmisc3;
11960 53 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11961
11962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(success)
11963 {
11964
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(itemguy) // Hand down the carried item
11965 {
11966 guycarryingitem = guys.Count()-1;
11967 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11968 itemguy = false;
11969 }
11970
11971 53 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11972 53 }
11973
11974 53 stop_bgsfx(index);
11975 53 return true;
11976 }
11977 else
11978 {
11979 18 clk4=0;
11980 }
11981 18 }
11982 35728 }
11983 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11984
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 1247602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1730770 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11985 {
11986
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11987 {
11988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
11989 {
11990 fakez=int32_t(step/zslongToFix(dstep*100));
11991 // Some variance in keese flight heights when away from Hero
11992 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
11993
11994 }
11995 else
11996 {
11997 483168 z=int32_t(step/zslongToFix(dstep*100));
11998 // Some variance in keese flight heights when away from Hero
11999
2/2
✓ Branch 0 taken 90771 times.
✓ Branch 1 taken 392397 times.
483168 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
12000 }
12001 483168 }
12002 else
12003 {
12004 if (moveflags & FLAG_USE_FAKE_Z)
12005 {
12006 fakez=int32_t(step/zslongToFix(dstep*100));
12007 // Some variance in keese flight heights when away from Hero
12008 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
12009
12010 }
12011 else
12012 {
12013 z=int32_t(step/zslongToFix(dstep*100));
12014 // Some variance in keese flight heights when away from Hero
12015 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
12016 }
12017 }
12018 483168 }
12019
12020 1766498 return enemy::animate(index);
12021 1835461 }
12022
12023 561528 void eKeese::drawshadow(BITMAP *dest, bool translucent)
12024 {
12025 561528 int32_t tempy=yofs;
12026 561528 flip = 0;
12027 561528 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
12028
12029
2/2
✓ Branch 0 taken 214011 times.
✓ Branch 1 taken 347517 times.
561528 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
12030
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 259006 times.
561528 if(!get_qr(qr_ENEMIESZAXIS))
12031 {
12032 259006 yofs+=int32_t(step/zslongToFix(dstep*10));
12033 259006 }
12034
12035
6/6
✓ Branch 0 taken 557934 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 255412 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
561528 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
12036 549864 enemy::drawshadow(dest, translucent);
12037 561528 yofs=tempy;
12038 561528 }
12039
12040 4144206 void eKeese::draw(BITMAP *dest)
12041 {
12042 4144206 update_enemy_frame();
12043 4144206 enemy::draw(dest);
12044 4144206 }
12045
12046 11346 void eWizzrobe::submerge(bool set)
12047 {
12048
2/2
✓ Branch 0 taken 11318 times.
✓ Branch 1 taken 28 times.
11346 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
12049 {
12050 11318 hxofs = set?1000:0;
12051 11318 return;
12052 }
12053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
12054 28 submerged = set;
12055
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
12056 14 hxofs+=1000;
12057 14 else hxofs -= 1000;
12058 11346 }
12059 4300 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12060 4300 {
12061 2150 hxofs = 0;
12062 2150 submerged = false;
12063
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 switch(dmisc1)
12064 {
12065 case 0:
12066
1/2
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
1230 submerge(true);
12067 1230 fading=fade_invisible;
12068 // Set clk to just before the 'reappear' threshold
12069
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1230 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1230 times.
✓ Branch 4 taken 960 times.
✓ Branch 5 taken 270 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 960 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 270 times.
1230 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
12070 1230 break;
12071
12072 default:
12073 920 dir=(loadside==right)?right:left;
12074 920 misc=-3;
12075 920 break;
12076 }
12077
12078 //netst+2880;
12079 2150 charging=false;
12080 2150 firing=false;
12081 2150 fclk=0;
12082
2/2
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 920 times.
2150 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
12083 2150 SIZEflags = d->SIZEflags;
12084
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12085 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12086 // al_trace("Enemy txsz:%i\n", txsz);
12087
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
12089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
12090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12091
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
12092 {
12093 hxofs = (submerged?hxofs:0)+d->hxofs;
12094 }
12095
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12096 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12099 {
12100 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12101 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12102 }
12103
12104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12105 2150 }
12106
12107 1015605 bool eWizzrobe::animate(int32_t index)
12108 {
12109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015605 times.
1015605 if(switch_hooked) return enemy::animate(index);
12110
2/4
✓ Branch 0 taken 1015605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1015605 times.
1015605 if(fallclk||drownclk) return enemy::animate(index);
12111
2/2
✓ Branch 0 taken 21786 times.
✓ Branch 1 taken 993819 times.
1015605 if(dying)
12112 {
12113 21786 return Dead(index);
12114 }
12115
12116
2/2
✓ Branch 0 taken 962127 times.
✓ Branch 1 taken 31692 times.
993819 if(clk==0)
12117 {
12118 31692 removearmos(x,y,ffcactivated);
12119 31692 }
12120
12121
2/2
✓ Branch 0 taken 502494 times.
✓ Branch 1 taken 491325 times.
993819 if(dmisc1) // Floating
12122 {
12123 502494 wizzrobe_attack();
12124 502494 }
12125 else // Teleporting
12126 {
12127
5/6
✓ Branch 0 taken 485972 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 483262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
491325 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
12128 {
12129 5353 fading=0;
12130 5353 submerge(false);
12131 5353 solid_update(false);
12132 5353 }
12133
8/8
✓ Branch 0 taken 469803 times.
✓ Branch 1 taken 2887 times.
✓ Branch 2 taken 2507 times.
✓ Branch 3 taken 2430 times.
✓ Branch 4 taken 2393 times.
✓ Branch 5 taken 2075 times.
✓ Branch 6 taken 2001 times.
✓ Branch 7 taken 1876 times.
485972 else switch(clk)
12134 {
12135 case 0:
12136
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2406 times.
2887 if(!dmisc2)
12137 {
12138 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
12139 // but should not appear on dungeon walls.
12140
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1997 times.
2406 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
12141
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1925 times.
1997 else if (editorflags&ENEMY_FLAG5)
12142 {
12143 //2.10 Windrobe
12144 //randomise location and face Hero
12145 72 int32_t t=0;
12146 72 bool placed=false;
12147
12148
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 72 times.
178 while(!placed && t<160)
12149 {
12150
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 55 times.
106 if(isdungeon())
12151 {
12152 51 x=((zc_oldrand()%12)+2)*16;
12153 51 y=((zc_oldrand()%7)+2)*16;
12154 51 }
12155 else
12156 {
12157 55 x=((zc_oldrand()%14)+1)*16;
12158 55 y=((zc_oldrand()%9)+1)*16;
12159 }
12160
12161
6/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 72 times.
184 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12162 {
12163 72 placed=true;
12164 72 }
12165
12166 106 ++t;
12167 }
12168
12169
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 46 times.
72 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12170 {
12171
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5 times.
26 if(y<Hero.getY())
12172 {
12173 21 dir=down;
12174 21 }
12175 else
12176 {
12177 5 dir=up;
12178 }
12179 26 }
12180 else
12181 {
12182
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
46 if(x<Hero.getX())
12183 {
12184 25 dir=right;
12185 25 }
12186 else
12187 {
12188 21 dir=left;
12189 }
12190 }
12191
12192
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!placed) // can't place him, he's gone
12193 return true;
12194
12195
12196 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
12197 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
12198 72 }
12199 1925 else place_on_axis(true, dmisc4!=0);
12200 2406 }
12201 else
12202 {
12203 481 int32_t t=0;
12204 481 bool placed=false;
12205
12206
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
12207 {
12208
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
12209 {
12210 624 x=((zc_oldrand()%12)+2)*16;
12211 624 y=((zc_oldrand()%7)+2)*16;
12212 624 }
12213 else
12214 {
12215 17 x=((zc_oldrand()%14)+1)*16;
12216 17 y=((zc_oldrand()%9)+1)*16;
12217 }
12218
12219
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12220 {
12221 481 placed=true;
12222 481 }
12223
12224 641 ++t;
12225 }
12226
12227
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12228 {
12229
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
12230 {
12231 97 dir=down;
12232 97 }
12233 else
12234 {
12235 62 dir=up;
12236 }
12237 159 }
12238 else
12239 {
12240
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
12241 {
12242 166 dir=right;
12243 166 }
12244 else
12245 {
12246 156 dir=left;
12247 }
12248 }
12249
12250
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
12251 return true;
12252 }
12253
12254 2887 fading=fade_flicker;
12255 2887 submerge(false);
12256 2887 solid_update(false);
12257 2887 break;
12258
12259 case 64:
12260 2507 fading=0;
12261 2507 charging=true;
12262 2507 break;
12263
12264 case 73:
12265 2430 charging=false;
12266 2430 firing=40;
12267 2430 break;
12268
12269 case 83:
12270 2393 wizzrobe_attack_for_real();
12271 2393 break;
12272
12273 case 119:
12274 2075 firing=false;
12275 2075 charging=true;
12276 2075 break;
12277
12278 case 128:
12279 2001 fading=fade_flicker;
12280 2001 charging=false;
12281 2001 break;
12282
12283 case 146:
12284 1876 fading=fade_invisible;
12285 1876 submerge(true);
12286 1876 solid_update(false);
12287
12288 [[fallthrough]];
12289 default:
12290
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471679 times.
✓ Branch 2 taken 468788 times.
✓ Branch 3 taken 2891 times.
471679 if(clk>=(146+zc_max(0,dmisc5)))
12291 2891 clk=-1;
12292
12293 471679 break;
12294 }
12295 }
12296
12297 993819 return enemy::animate(index);
12298 1015605 }
12299
12300 3874 void eWizzrobe::wizzrobe_attack_for_real()
12301 {
12302
1/2
✓ Branch 0 taken 3874 times.
✗ Branch 1 not taken.
3874 if(wpn==0) // Edited enemies
12303 return;
12304
12305
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 3069 times.
3874 if(dmisc2 == 0) //normal weapon
12306 {
12307 3069 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12308 3069 sfx(WAV_WAND,pan(int32_t(x)));
12309 3069 }
12310
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 450 times.
805 else if(dmisc2 == 1) // ring of fire
12311 {
12312 355 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12313 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12314 355 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12315 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12316 355 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12317 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12318 355 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12319 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12320 355 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12321 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12322 355 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12323 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12324 355 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12325 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12326 355 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12327 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12328 355 sfx(WAV_FIRE,pan(int32_t(x)));
12329
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 283 times.
355 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
12330 else
12331 {
12332
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
12333 {
12334 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
12335
12336 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
12337 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
12338 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
12339 case ewRock: sfx(51,pan(int32_t(x))); break;
12340 case ewMagic: sfx(32,pan(int32_t(x))); break;
12341 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12342 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12343 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12344 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12345 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
12346 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
12347 case ewWind: sfx(32,pan(int32_t(x))); break;
12348 case ewFlame2: sfx(13,pan(int32_t(x))); break;
12349 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
12350 case ewIce: sfx(44,pan(int32_t(x))); break;
12351 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
12352 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
12353
12354 }
12355 }
12356 355 }
12357
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
12358 {
12359 436 int32_t bc=0;
12360
12361
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
12362 {
12363
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12364 {
12365 2804 ++bc;
12366 2804 }
12367 5394 }
12368
12369
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
12370 {
12371 428 int32_t kids = guys.Count();
12372 428 int32_t bats=(zc_oldrand()%3)+1;
12373
12374
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
12375 {
12376 // Summon bats (or anything)
12377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
12378 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12379 868 }
12380
12381 428 sfx(WAV_FIRE,pan(int32_t(x)));
12382 428 }
12383 436 }
12384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
12385 {
12386
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
12387 {
12388 return;
12389 }
12390
12391 14 int32_t kids = guys.Count();
12392
12393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
12394 {
12395 14 int32_t newguys=(zc_oldrand()%3)+1;
12396 14 bool summoned=false;
12397
12398
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
12399 {
12400 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12401 25 int32_t x2=0;
12402 25 int32_t y2=0;
12403
12404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
12405 {
12406 27 x2=16*((zc_oldrand()%12)+2);
12407 27 y2=16*((zc_oldrand()%7)+2);
12408
12409
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12410 {
12411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12412 {
12413 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
12415 {
12416 ((enemy*)guys.spr(kids+i))->fakez = 64;
12417 ((enemy*)guys.spr(kids+i))->z = 0;
12418 }
12419 25 }
12420
12421 25 summoned=true;
12422 25 break;
12423 }
12424 2 }
12425 25 }
12426
12427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
12428 {
12429 14 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12430 14 }
12431 14 }
12432 14 }
12433 3874 }
12434
12435
12436 502494 void eWizzrobe::wizzrobe_attack()
12437 {
12438
9/12
✓ Branch 0 taken 487591 times.
✓ Branch 1 taken 14903 times.
✓ Branch 2 taken 487591 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 468976 times.
✓ Branch 5 taken 18615 times.
✓ Branch 6 taken 466825 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 466825 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 466825 times.
502494 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12439 35669 return;
12440
12441
3/8
✓ Branch 0 taken 448202 times.
✓ Branch 1 taken 18623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 448202 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
466825 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12442 {
12443 18623 fix_coords();
12444
12445
5/5
✓ Branch 0 taken 2316 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 8722 times.
✓ Branch 3 taken 4845 times.
✓ Branch 4 taken 2137 times.
18623 switch(misc)
12446 {
12447 case 1: //walking
12448
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 1147 times.
4845 if(!m_walkflag(x,y,spw_door, dir))
12449 1147 misc=0;
12450 else
12451 {
12452 3698 clk3=16;
12453
12454
2/2
✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 513 times.
3698 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12455 {
12456 513 wizzrobe_newdir(0);
12457 513 }
12458 }
12459
12460 4845 break;
12461
12462 case 2: //phasing
12463 {
12464 2137 int32_t jx=x;
12465 2137 int32_t jy=y;
12466 2137 int32_t jdir=-1;
12467
12468
5/5
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 266 times.
2137 switch(zc_oldrand()&7)
12469 {
12470 case 0:
12471 279 jx-=32;
12472 279 jy-=32;
12473 279 jdir=15;
12474 279 break;
12475
12476 case 1:
12477 245 jx+=32;
12478 245 jy-=32;
12479 245 jdir=9;
12480 245 break;
12481
12482 case 2:
12483 264 jx+=32;
12484 264 jy+=32;
12485 264 jdir=11;
12486 264 break;
12487
12488 case 3:
12489 266 jx-=32;
12490 266 jy+=32;
12491 266 jdir=13;
12492 266 break;
12493 }
12494
12495
10/10
✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 1083 times.
✓ Branch 2 taken 940 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 633 times.
✓ Branch 9 taken 130 times.
2137 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12496 {
12497 633 misc=3;
12498 633 clk3=32;
12499 633 dir=jdir;
12500 633 break;
12501 }
12502 1504 }
12503 [[fallthrough]];
12504 case 3:
12505 2107 dir&=3;
12506 2107 misc=0;
12507 [[fallthrough]];
12508 case 0:
12509 10829 wizzrobe_newdir(64);
12510 [[fallthrough]];
12511 default:
12512
2/2
✓ Branch 0 taken 11753 times.
✓ Branch 1 taken 1392 times.
13145 if(!canmove(dir,(zfix)1,spw_door,false))
12513 {
12514
2/2
✓ Branch 0 taken 1326 times.
✓ Branch 1 taken 66 times.
1392 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12515 {
12516 1326 misc=1;
12517 1326 clk3=16;
12518 1326 }
12519 else
12520 {
12521 66 wizzrobe_newdir(64);
12522 66 misc=0;
12523 66 clk3=32;
12524 }
12525 1392 }
12526 else
12527 {
12528 11753 clk3=32;
12529 }
12530
12531 13145 break;
12532 }
12533
12534
2/2
✓ Branch 0 taken 16596 times.
✓ Branch 1 taken 2027 times.
18623 if(misc<0)
12535 2027 ++misc;
12536 18623 }
12537
12538 466825 --clk3;
12539
12540
3/3
✓ Branch 0 taken 98770 times.
✓ Branch 1 taken 332655 times.
✓ Branch 2 taken 35400 times.
466825 switch(misc)
12541 {
12542 case 1:
12543 case 3:
12544 98770 step=1;
12545 98770 break;
12546
12547 case 2:
12548 35400 step=0;
12549 35400 break;
12550
12551 default:
12552 332655 step=0.5;
12553 332655 break;
12554
12555 }
12556
12557 466825 move(step);
12558
12559 // if(d->misc1 && misc<=0 && clk3==28)
12560
5/6
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332655 times.
✓ Branch 3 taken 134170 times.
✓ Branch 4 taken 321156 times.
✓ Branch 5 taken 11499 times.
466825 if(dmisc1 && misc<=0 && clk3==28)
12561 {
12562
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1619 times.
11499 if(dmisc2 != 1)
12563 {
12564
2/2
✓ Branch 0 taken 8754 times.
✓ Branch 1 taken 1126 times.
9880 if(lined_up(8,false) == dir)
12565 {
12566 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12567 // sfx(WAV_WAND,pan(int32_t(x)));
12568 1126 wizzrobe_attack_for_real();
12569 1126 fclk=30;
12570 1126 }
12571 9880 }
12572 else
12573 {
12574
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 355 times.
1619 if((zc_oldrand()%500)>=400)
12575 {
12576 355 wizzrobe_attack_for_real();
12577 355 fclk=30;
12578 355 }
12579 }
12580 11499 }
12581
12582
4/4
✓ Branch 0 taken 287050 times.
✓ Branch 1 taken 179775 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 284850 times.
466825 if(misc==0 && (zc_oldrand()&127)==0)
12583 2200 misc=2;
12584
12585
4/4
✓ Branch 0 taken 37600 times.
✓ Branch 1 taken 429225 times.
✓ Branch 2 taken 35712 times.
✓ Branch 3 taken 1888 times.
466825 if(misc==2 && clk3==4)
12586 1888 fix_coords();
12587
12588
2/4
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466825 times.
466825 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12589 {
12590
2/2
✓ Branch 0 taken 424649 times.
✓ Branch 1 taken 42176 times.
466825 if(fclk>0)
12591 {
12592 42176 --fclk;
12593 42176 }
12594 466825 }
12595
12596 502494 }
12597
12598 11408 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12599 {
12600 // Wizzrobes shouldn't move to the edge of the screen;
12601 // if they're already there, they should move toward the center
12602
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11404 times.
11408 if(x<32)
12603 4 dir=right;
12604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(x>=224)
12605 dir=left;
12606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(y<32)
12607 dir=down;
12608
1/2
✓ Branch 0 taken 11404 times.
✗ Branch 1 not taken.
11404 else if(y>=144)
12609 dir=up;
12610 else
12611 11404 newdir(4,homing,spw_wizzrobe);
12612 11408 }
12613
12614 1018464 void eWizzrobe::draw(BITMAP *dest)
12615 {
12616 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12617
13/14
✓ Branch 0 taken 512388 times.
✓ Branch 1 taken 506076 times.
✓ Branch 2 taken 428953 times.
✓ Branch 3 taken 83435 times.
✓ Branch 4 taken 53103 times.
✓ Branch 5 taken 459285 times.
✓ Branch 6 taken 52418 times.
✓ Branch 7 taken 685 times.
✓ Branch 8 taken 51661 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 49440 times.
✓ Branch 11 taken 2221 times.
✓ Branch 12 taken 49440 times.
✗ Branch 13 not taken.
1018464 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12618 49440 return;
12619
12620 969024 int32_t tempint=dummy_int[1];
12621 969024 bool tempbool1=dummy_bool[1];
12622 969024 bool tempbool2=dummy_bool[2];
12623 969024 dummy_int[1]=fclk;
12624 969024 dummy_bool[1]=charging;
12625 969024 dummy_bool[2]=firing;
12626 969024 update_enemy_frame();
12627 969024 dummy_int[1]=tempint;
12628 969024 dummy_bool[1]=tempbool1;
12629 969024 dummy_bool[2]=tempbool2;
12630 969024 enemy::draw(dest);
12631 1018464 }
12632
12633 /*********************************/
12634 /********** Bosses ***********/
12635 /*********************************/
12636
12637 278 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12638 278 {
12639 139 fading=fade_flash_die;
12640 //nets+5120;
12641
6/8
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 3 times.
139 if(dir==down&&y>=128)
12642 {
12643 3 dir=up;
12644 3 }
12645
12646
5/8
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
139 if(dir==right&&x>=208)
12647 {
12648 dir=left;
12649 }
12650 139 SIZEflags = d->SIZEflags;
12651
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12652 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12653 // al_trace("Enemy txsz:%i\n", txsz);
12654
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12655
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12656
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12658
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12659
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12660 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12663 {
12664 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12665 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12666 }
12667
12668
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12669 139 }
12670
12671 94046 bool eDodongo::animate(int32_t index)
12672 {
12673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94046 times.
94046 if(switch_hooked) return enemy::animate(index);
12674
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 90876 times.
94046 if(dying)
12675 {
12676 3170 return Dead(index);
12677 }
12678
12679
2/2
✓ Branch 0 taken 90462 times.
✓ Branch 1 taken 414 times.
90876 if(clk==0)
12680 {
12681 414 removearmos(x,y,ffcactivated);
12682 414 }
12683
12684
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 82140 times.
90876 if(clk2) // ate a bomb
12685 {
12686
2/2
✓ Branch 0 taken 8645 times.
✓ Branch 1 taken 91 times.
8736 if(--clk2==0)
12687 91 hp-=misc; // store bomb's power in misc
12688 8736 }
12689 else
12690 82140 constant_walk(rate,homing,spw_clipright);
12691
12692 90876 hit_width = (dir<=down) ? 16 : 32;
12693 // hysz = (dir>=left) ? 16 : 32;
12694
12695 90876 return enemy::animate(index);
12696 94046 }
12697
12698 94037 void eDodongo::draw(BITMAP *dest)
12699 {
12700 94037 tile=o_tile;
12701
12702
2/2
✓ Branch 0 taken 2272 times.
✓ Branch 1 taken 91765 times.
94037 if(clk<0)
12703 {
12704 2272 enemy::drawzcboss(dest);
12705 2272 return;
12706 }
12707
12708 91765 update_enemy_frame();
12709 91765 enemy::drawzcboss(dest);
12710
12711
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 54233 times.
91765 if(dummy_int[1]!=0) //additional tiles
12712 {
12713 54233 tile+=dummy_int[1]; //second tile is previous tile
12714 54233 xofs-=16; //new xofs change
12715 54233 enemy::drawzcboss(dest);
12716 54233 xofs+=16;
12717 54233 }
12718
12719 94037 }
12720
12721 6225 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12722 {
12723 6225 int32_t wpnId = w->id;
12724 6225 int32_t power = w->power;
12725 6225 int32_t wpnx = w->x;
12726 6225 int32_t wpny = w->y;
12727
12728
5/12
✓ Branch 0 taken 6225 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6225 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1749 times.
✓ Branch 5 taken 4476 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1749 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6225 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12729 4476 return 0;
12730
12731
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 1028 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98 times.
1749 switch(wpnId)
12732 {
12733 case wPhantom:
12734 return 0;
12735
12736 case wFire:
12737 case wBait:
12738 case wWhistle:
12739 case wWind:
12740 case wSSparkle:
12741 case wFSparkle:
12742 return 0;
12743
12744 case wLitBomb:
12745 case wLitSBomb:
12746
6/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 91 times.
607 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12747 516 return 0;
12748
12749 91 clk2=96;
12750 91 misc=power;
12751
12752
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(wpnId==wLitSBomb)
12753 3 item_set=isSBOMB100;
12754
12755 91 return 1;
12756
12757 case wBomb:
12758 case wSBomb:
12759
6/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 739 times.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 667 times.
1028 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12760 361 return 0;
12761
12762 667 stunclk=160;
12763 667 misc=wpnId; // store wpnId
12764 667 return 1;
12765
12766 case wSword:
12767
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 67 times.
98 if(stunclk)
12768 {
12769 67 sfx(WAV_EHIT,pan(int32_t(x)));
12770 67 hp=0;
12771 67 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12772 67 fading=0; // don't flash
12773 67 return 1;
12774 }
12775
12776 [[fallthrough]];
12777 default:
12778 47 sfx(WAV_CHINK,pan(int32_t(x)));
12779 47 }
12780
12781 47 return 1;
12782 6225 }
12783
12784 4 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12785 4 {
12786 2 fading=fade_flash_die;
12787 //nets+5180;
12788 2 previous_dir=-1;
12789
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
12790 {
12791 dir=up;
12792 }
12793
12794
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
12795 {
12796 dir=left;
12797 }
12798 2 SIZEflags = d->SIZEflags;
12799
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12800 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12801 // al_trace("Enemy txsz:%i\n", txsz);
12802
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12804
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12805
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12806
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12807
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12808 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12811 {
12812 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12813 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12814 }
12815
12816
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12817 2 }
12818
12819 848 bool eDodongo2::animate(int32_t index)
12820 {
12821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
12822
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
12823 {
12824 36 return Dead(index);
12825 }
12826
12827
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
12828 {
12829 4 removearmos(x,y,ffcactivated);
12830 4 }
12831
12832
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
12833 {
12834
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
12835 2 hp-=misc; // store bomb's power in misc
12836 192 }
12837 else
12838 620 constant_walk(rate,homing,spw_clipbottomright);
12839
12840 812 hit_width = (dir<=down) ? 16 : 32;
12841 812 hit_height = (dir>=left) ? 16 : 32;
12842 812 hxofs=(dir>=left)?-8:0;
12843 812 hyofs=(dir<left)?-8:0;
12844
12845 812 return enemy::animate(index);
12846 848 }
12847
12848 848 void eDodongo2::draw(BITMAP *dest)
12849 {
12850
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
12851 {
12852 30 enemy::drawzcboss(dest);
12853 30 return;
12854 }
12855
12856 818 int32_t tempx=xofs;
12857 818 int32_t tempy=yofs;
12858 818 update_enemy_frame();
12859 818 enemy::drawzcboss(dest);
12860 818 tile+=dummy_int[1]; //second tile change
12861 818 xofs+=dummy_int[2]; //new xofs change
12862 818 yofs+=dummy_int[3]; //new yofs change
12863 818 enemy::drawzcboss(dest);
12864 818 xofs=tempx;
12865 818 yofs=tempy;
12866 848 }
12867
12868 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12869 {
12870 165 int32_t wpnId = w->id;
12871 165 int32_t power = w->power;
12872 165 int32_t wpnx = w->x;
12873 165 int32_t wpny = w->y;
12874
12875
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
12876 145 return 0;
12877
12878
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
12879 {
12880 case wPhantom:
12881 return 0;
12882
12883 case wFire:
12884 case wBait:
12885 case wWhistle:
12886 case wWind:
12887 case wSSparkle:
12888 case wFSparkle:
12889 return 0;
12890
12891 case wLitBomb:
12892 case wLitSBomb:
12893
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
12894 {
12895 case up:
12896 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12897 return 0;
12898
12899 break;
12900
12901 case down:
12902 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12903 return 0;
12904
12905 break;
12906
12907 case left:
12908
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12909 return 0;
12910
12911 2 break;
12912
12913 case right:
12914 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12915 return 0;
12916
12917 break;
12918 }
12919
12920 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12921 // return 0;
12922 2 clk2=96;
12923 2 misc=power;
12924
12925
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
12926 item_set=isSBOMB100;
12927
12928 2 return 1;
12929
12930 case wBomb:
12931 case wSBomb:
12932
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
12933 {
12934 case up:
12935 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12936 return 0;
12937
12938 break;
12939
12940 case down:
12941 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12942 return 0;
12943
12944 break;
12945
12946 case left:
12947
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12948 return 0;
12949
12950 15 break;
12951
12952 case right:
12953 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12954 return 0;
12955
12956 break;
12957 }
12958
12959 15 stunclk=160;
12960 15 misc=wpnId; // store wpnId
12961 15 return 1;
12962
12963 case wSword:
12964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
12965 {
12966 2 sfx(WAV_EHIT,pan(int32_t(x)));
12967 2 hp=0;
12968 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12969 2 fading=0; // don't flash
12970 2 return 1;
12971 }
12972
12973 [[fallthrough]];
12974 default:
12975 1 sfx(WAV_CHINK,pan(int32_t(x)));
12976 1 }
12977
12978 1 return 1;
12979 165 }
12980
12981 152 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12982 152 {
12983 //these are here to bypass compiler warnings about unused arguments
12984
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( !(editorflags & ENEMY_FLAG5) )
12985 {
12986
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 x = dmisc1 ? 64 : 176;
12987
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 y = 64;
12988 76 }
12989 else { x = X; y = Y; }
12990
12991 //nets+5940;
12992
3/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 33 times.
76 if(get_qr(qr_NEWENEMYTILES))
12993 {
12994 43 }
12995 else
12996 {
12997
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 7 times.
33 if(dmisc1)
12998 {
12999 7 flip=1;
13000 7 }
13001 }
13002
13003
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13004 76 clk3=32;
13005 76 clk2=0;
13006 76 clk4=clk;
13007 76 dir=left;
13008 76 SIZEflags = d->SIZEflags;
13009
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13010 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13011 // al_trace("Enemy txsz:%i\n", txsz);
13012
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13016
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13017
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13018 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13021 {
13022 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13023 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13024 }
13025
13026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13027 76 }
13028
13029 50824 bool eAquamentus::animate(int32_t index)
13030 {
13031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50824 times.
50824 if(switch_hooked) return enemy::animate(index);
13032
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 49558 times.
50824 if(dying)
13033 1266 return Dead(index);
13034
13035 // fbx=x+((id==eRAQUAM)?4:-4);
13036
2/2
✓ Branch 0 taken 49337 times.
✓ Branch 1 taken 221 times.
49558 if(clk==0)
13037 {
13038 221 removearmos(x,y,ffcactivated);
13039 221 }
13040
13041 49558 fbx=x;
13042
13043 /*
13044 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
13045 {
13046 fbx+=16;
13047 }
13048 */
13049
2/2
✓ Branch 0 taken 49241 times.
✓ Branch 1 taken 317 times.
49558 if(--clk3==0)
13050 {
13051 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
13052 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
13053 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
13054 317 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
13055 317 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
13056 317 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
13057 317 sfx(wpnsfx(wpn),pan(int32_t(x)));
13058 317 }
13059
13060
4/4
✓ Branch 0 taken 15161 times.
✓ Branch 1 taken 34397 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 14907 times.
49558 if(clk3<-80 && !(zc_oldrand()&63))
13061 {
13062 254 clk3=32;
13063 254 }
13064
13065
2/2
✓ Branch 0 taken 48766 times.
✓ Branch 1 taken 792 times.
49558 if(!((clk4+1)&63))
13066 {
13067 792 int32_t d2=(zc_oldrand()%3)+1;
13068
13069
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 533 times.
792 if(d2>=left)
13070 {
13071 533 dir=d2;
13072 533 }
13073
13074
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 442 times.
792 if(dmisc1)
13075 {
13076
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 35 times.
350 if(x<=40)
13077 {
13078 35 dir=right;
13079 35 }
13080
13081
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(x>=104)
13082 {
13083 dir=left;
13084 }
13085 350 }
13086 else
13087 {
13088
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 14 times.
442 if(x<=136)
13089 {
13090 14 dir=right;
13091 14 }
13092
13093
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 22 times.
442 if(x>=200)
13094 {
13095 22 dir=left;
13096 22 }
13097 }
13098 792 }
13099
13100
4/4
✓ Branch 0 taken 48440 times.
✓ Branch 1 taken 1118 times.
✓ Branch 2 taken 42352 times.
✓ Branch 3 taken 6088 times.
49558 if(clk4>=-1 && !((clk4+1)&7))
13101 {
13102
2/2
✓ Branch 0 taken 3226 times.
✓ Branch 1 taken 2862 times.
6088 if(dir==left)
13103 {
13104 3226 x-=1;
13105 3226 }
13106 else
13107 {
13108 2862 x+=1;
13109 }
13110 6088 }
13111
13112 49558 clk4=(clk4+1)%256;
13113
13114 49558 return enemy::animate(index);
13115 50824 }
13116
13117 51235 void eAquamentus::draw(BITMAP *dest)
13118 {
13119
2/2
✓ Branch 0 taken 29751 times.
✓ Branch 1 taken 21484 times.
51235 if(get_qr(qr_NEWENEMYTILES))
13120 {
13121 29751 xofs=(dmisc1?-16:0);
13122
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29751 times.
✓ Branch 2 taken 12244 times.
✓ Branch 3 taken 17507 times.
29751 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
13123
13124
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 29061 times.
29751 if(dying)
13125 {
13126 690 xofs=0;
13127 690 enemy::draw(dest);
13128 690 }
13129 else
13130 {
13131 29061 drawblock(dest,15);
13132 }
13133 29751 }
13134 else
13135 {
13136 21484 int32_t xblockofs=((dmisc1)?-16:16);
13137 21484 xofs=0;
13138
13139
4/4
✓ Branch 0 taken 20982 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 20406 times.
21484 if(clk<0 || dying)
13140 {
13141 1078 enemy::draw(dest);
13142 1078 return;
13143 }
13144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20406 times.
20406 if ( do_animation )
13145 {
13146 // face (0=firing, 2=resting)
13147 20406 tile=o_tile+((clk3>0)?0:2);
13148 20406 enemy::draw(dest);
13149 // tail (
13150 20406 tile=o_tile+((clk&16)?1:3);
13151 20406 xofs=xblockofs;
13152 20406 enemy::draw(dest);
13153 // body
13154 20406 yofs+=16;
13155 20406 xofs=0;
13156 20406 tile=o_tile+((clk&16)?20:22);
13157 20406 enemy::draw(dest);
13158 20406 xofs=xblockofs;
13159 20406 tile=o_tile+((clk&16)?21:23);
13160 20406 enemy::draw(dest);
13161 20406 yofs-=16;
13162 20406 }
13163 else enemy::draw(dest);
13164 }
13165 51235 }
13166
13167 10639 bool eAquamentus::hit(weapon *w)
13168 {
13169
3/6
✓ Branch 0 taken 10639 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10639 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10639 times.
10639 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
13170
13171
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 7833 times.
10639 switch(w->id)
13172 {
13173 case wBeam:
13174 case wRefBeam:
13175 case wMagic:
13176 2806 hit_height=32;
13177 2806 }
13178
13179
4/4
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 2202 times.
10639 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
13180 10639 hit_height=16;
13181 10639 return ret;
13182
13183 10639 }
13184
13185 110 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
13186 110 {
13187
13188
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( !(editorflags & ENEMY_FLAG5) )
13189 {
13190
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 x = 128;
13191
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 y = 48;
13192 55 }
13193 else { x = X; y = Y; }
13194
13195 55 Clk=Clk;
13196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(flags & guy_fadeflicker)
13197 {
13198 clk=0;
13199 superman = 1;
13200 fading=fade_flicker;
13201 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13202 }
13203
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36 times.
55 else if(flags & guy_fadeinstant)
13204 {
13205 36 clk=0;
13206 36 }
13207 55 hxofs=-16;
13208 55 hit_width=48;
13209 55 clk4=0;
13210
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13211
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 dir=zc_oldrand()%3+1;
13212 55 SIZEflags = d->SIZEflags;
13213
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13214 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13215 // al_trace("Enemy txsz:%i\n", txsz);
13216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
13217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
13218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
13219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
13220
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
13221
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
13222 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13223
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
13224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13225 {
13226 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
13227 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13228 }
13229
13230
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
13231
13232 //nets+5340;
13233 55 }
13234
13235 46569 bool eGohma::animate(int32_t index)
13236 {
13237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46569 times.
46569 if(switch_hooked) return enemy::animate(index);
13238
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 45799 times.
46569 if(dying)
13239 770 return Dead(index);
13240
13241
2/2
✓ Branch 0 taken 45788 times.
✓ Branch 1 taken 11 times.
45799 if(fading)
13242 {
13243
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(++clk4 > 60)
13244 {
13245 11 clk4=0;
13246 11 superman=0;
13247 11 fading=0;
13248 11 clk=0;
13249
13250 11 }
13251 else return enemy::animate(index);
13252 11 }
13253
13254
2/2
✓ Branch 0 taken 45583 times.
✓ Branch 1 taken 216 times.
45799 if(clk==0)
13255 {
13256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if (ffcactivated) removearmosffc(ffcactivated-1);
13257 else
13258 {
13259
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 removearmos(zc_max(x-16, zfix(0)),y);
13260 216 did_armos = false;
13261 216 removearmos(x,y);
13262 216 did_armos = false;
13263
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 removearmos(zc_min(x+16, zfix(255)),y);
13264 }
13265 216 }
13266
13267
2/2
✓ Branch 0 taken 45511 times.
✓ Branch 1 taken 288 times.
45799 if(clk<0) return enemy::animate(index);
13268
13269 // Movement clk must be separate from animation clk because of the Clock item
13270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45511 times.
45511 if(!watch)
13271 45511 clk4++;
13272
13273
2/2
✓ Branch 0 taken 44826 times.
✓ Branch 1 taken 685 times.
45511 if((clk4&63)==0)
13274 {
13275
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 327 times.
685 if(clk4&64)
13276 358 dir^=1;
13277 else
13278 327 dir=zc_oldrand()%3+1;
13279 685 }
13280
13281
2/2
✓ Branch 0 taken 44776 times.
✓ Branch 1 taken 735 times.
45511 if((clk&63)==3)
13282 {
13283
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 187 times.
735 switch(dmisc1)
13284 {
13285 case 1:
13286 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
13287 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13288 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
13289 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
13290 187 break;
13291
13292 default:
13293
3/4
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 463 times.
548 if(dmisc1 != 1 && dmisc1 != 2)
13294 {
13295 463 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13296 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13297 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13298 463 }
13299
13300 548 break;
13301 }
13302 735 }
13303
13304
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 40155 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
45511 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
13305 {
13306
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
13307 {
13308 183 FireBreath(true);
13309 183 }
13310 1392 }
13311
13312
2/2
✓ Branch 0 taken 22736 times.
✓ Branch 1 taken 22775 times.
45511 if(clk4&1)
13313 22775 move((zfix)1);
13314
13315
2/2
✓ Branch 0 taken 45411 times.
✓ Branch 1 taken 100 times.
45511 if(++clk3>=400)
13316 100 clk3=0;
13317
13318 45511 return enemy::animate(index);
13319 46569 }
13320
13321 46567 void eGohma::draw(BITMAP *dest)
13322 {
13323 46567 tile=o_tile;
13324
13325
4/4
✓ Branch 0 taken 46279 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 45509 times.
46567 if(clk<0 || dying)
13326 {
13327 1058 enemy::drawzcboss(dest);
13328 1058 return;
13329 }
13330
13331
2/2
✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 12333 times.
45509 if(get_qr(qr_NEWENEMYTILES))
13332 {
13333 ///if ( do_animation )
13334 //Yuck. Gohma can just not have this capability right now.
13335 // left side
13336 33176 xofs=-16;
13337 33176 flip=0;
13338 // if(clk&16) tile=180;
13339 // else { tile=182; flip=1; }
13340 33176 tile+=(3*((clk&48)>>4));
13341 33176 enemy::drawzcboss(dest);
13342
13343 // right side
13344 33176 xofs=16;
13345 // tile=(180+182)-tile;
13346 33176 tile=o_tile;
13347 33176 tile+=(3*((clk&48)>>4))+2;
13348 33176 enemy::drawzcboss(dest);
13349
13350 // body
13351 33176 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13352 33176 tile=o_tile;
13353
13354 // tile+=(3*((clk&24)>>3))+2;
13355
2/2
✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 31417 times.
33176 if(clk3<16)
13356 1759 tile+=7;
13357
2/2
✓ Branch 0 taken 9419 times.
✓ Branch 1 taken 21998 times.
31417 else if(clk3<116)
13358 9419 tile+=10;
13359
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
13360 1315 tile+=7;
13361 else
13362 20683 tile+=((clk3-132)&24)?4:1;
13363
13364 33176 enemy::drawzcboss(dest);
13365
13366 33176 }
13367 else
13368 {
13369 // left side
13370 12333 xofs=-16;
13371 12333 flip=0;
13372
13373
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 6226 times.
12333 if(!(clk&16))
13374 {
13375 6226 tile+=2;
13376 6226 flip=1;
13377 6226 }
13378
13379 12333 enemy::draw(dest);
13380
13381 // right side
13382 12333 tile=o_tile;
13383 12333 xofs=16;
13384
13385
2/2
✓ Branch 0 taken 6226 times.
✓ Branch 1 taken 6107 times.
12333 if((clk&16)) tile+=2;
13386
13387 // tile=(180+182)-tile;
13388 12333 enemy::draw(dest);
13389
13390 // body
13391 12333 tile=o_tile;
13392 12333 xofs=0;
13393
13394
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 11613 times.
12333 if(clk3<16)
13395 720 tile+=4;
13396
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 7729 times.
11613 else if(clk3<116)
13397 3884 tile+=5;
13398
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7256 times.
7729 else if(clk3<132)
13399 473 tile+=4;
13400 7256 else tile+=((clk3-132)&8)?3:1;
13401
13402 12333 enemy::draw(dest);
13403
13404 }
13405 46567 }
13406
13407 230 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13408 {
13409 230 int32_t wpnId = w->id;
13410 230 int32_t power = w->power;
13411 230 int32_t wpnx = w->x;
13412 230 int32_t wpnDir = w->dir;
13413 230 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13414
13415
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 108 times.
230 if(def < 0)
13416 {
13417
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 13 times.
108 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13418 {
13419 41 sfx(WAV_CHINK,pan(int32_t(x)));
13420 41 return 1;
13421 }
13422 67 }
13423
13424 189 return enemy::takehit(w, realweap);
13425 230 }
13426
13427 396 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13428 396 {
13429 198 count_enemy=(id==(id&0xFFF));
13430 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13431 198 SIZEflags = d->SIZEflags;
13432
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13433 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13434 // al_trace("Enemy txsz:%i\n", txsz);
13435
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13437
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13439
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13440
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13441 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13442
1/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13444 {
13445 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13446 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13447 }
13448
13449
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13450 198 }
13451
13452 75067 bool eLilDig::animate(int32_t index)
13453 {
13454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75067 times.
75067 if(switch_hooked) return enemy::animate(index);
13455
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 72061 times.
75067 if(dying)
13456 3006 return Dead(index);
13457
13458
2/2
✓ Branch 0 taken 4113 times.
✓ Branch 1 taken 67948 times.
72061 if(clk==0)
13459 {
13460 4113 removearmos(x,y,ffcactivated);
13461 4113 }
13462
13463
2/2
✓ Branch 0 taken 48439 times.
✓ Branch 1 taken 23622 times.
72061 if(misc<=128)
13464 {
13465
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 22911 times.
23622 if(!(++misc&31))
13466 711 step+=0.25;
13467 23622 }
13468
13469 72061 variable_walk_8(rate,homing,hrate,spw_floater);
13470 72061 return enemy::animate(index);
13471 75067 }
13472
13473 74914 void eLilDig::draw(BITMAP *dest)
13474 {
13475 74914 tile = o_tile;
13476 // tile = 160;
13477 74914 int32_t fdiv = frate/4;
13478
1/2
✓ Branch 0 taken 74914 times.
✗ Branch 1 not taken.
74914 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13479
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13480 74914 efrate:((clk>=(frate>>1))?1:0);
13481
13482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74914 times.
74914 if ( do_animation )
13483 {
13484
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 if(get_qr(qr_NEWENEMYTILES))
13485 {
13486
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5312 times.
✓ Branch 8 taken 5035 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
13487 {
13488 case up: //u
13489 5853 flip=0;
13490 5853 break;
13491
13492 case l_up: //d
13493 5465 flip=0;
13494 5465 tile+=4;
13495 5465 break;
13496
13497 case l_down: //l
13498 5245 flip=0;
13499 5245 tile+=8;
13500 5245 break;
13501
13502 case left: //r
13503 5717 flip=0;
13504 5717 tile+=12;
13505 5717 break;
13506
13507 case r_down: //ul
13508 5242 flip=0;
13509 5242 tile+=20;
13510 5242 break;
13511
13512 case down: //ur
13513 4505 flip=0;
13514 4505 tile+=24;
13515 4505 break;
13516
13517 case r_up: //dl
13518 3937 flip=0;
13519 3937 tile+=28;
13520 3937 break;
13521
13522 case right: //dr
13523 5035 flip=0;
13524 5035 tile+=32;
13525 5035 break;
13526 }
13527
13528 46311 tile+=f2;
13529 46311 }
13530 else
13531 {
13532 28603 tile+=(clk>=6)?1:0;
13533 }
13534 74914 }
13535
13536 74914 enemy::draw(dest);
13537 74914 }
13538
13539 104 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13540 104 {
13541 52 superman=1;
13542
13543 52 SIZEflags = d->SIZEflags;
13544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13545 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13546 // al_trace("Enemy txsz:%i\n", txsz);
13547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13549 52 else hit_width=32;
13550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13551 52 else hit_height=32;
13552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13553 52 else hzsz=16; // hard to jump.
13554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13555 52 else hxofs=-8;
13556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13557 52 else hyofs=-8;
13558 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13559
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13561 {
13562 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13563 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13564 }
13565
13566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13567
13568
13569 52 }
13570
13571 22457 bool eBigDig::animate(int32_t index)
13572 {
13573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(switch_hooked) return enemy::animate(index);
13574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(dying)
13575 return Dead(index);
13576
13577
2/2
✓ Branch 0 taken 19263 times.
✓ Branch 1 taken 3194 times.
22457 if(clk==0)
13578 {
13579 3194 removearmos(x,y,ffcactivated);
13580 3194 }
13581
13582
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22369 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 44 times.
22457 switch(misc)
13583 {
13584 case 0:
13585 22369 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13586 22369 break;
13587
13588 case 1:
13589 44 ++misc;
13590 44 break;
13591
13592 case 2:
13593
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 44 times.
149 for(int32_t i=0; i<dmisc5; i++)
13594 {
13595 105 addenemy(x,y,dmisc1+0x1000,-15);
13596 105 }
13597
13598
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc6; i++)
13599 {
13600 16 addenemy(x,y,dmisc2+0x1000,-15);
13601 16 }
13602
13603
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc7; i++)
13604 {
13605 16 addenemy(x,y,dmisc3+0x1000,-15);
13606 16 }
13607
13608
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc8; i++)
13609 {
13610 16 addenemy(x,y,dmisc4+0x1000,-15);
13611 16 }
13612
13613
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1 times.
44 if(itemguy) // Hand down the carried item
13614 {
13615 1 guycarryingitem = guys.Count()-1;
13616 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13617 1 itemguy = false;
13618 1 }
13619
13620 44 stop_bgsfx(index);
13621
13622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13623
13624 44 return true;
13625 }
13626
13627 22413 return enemy::animate(index);
13628 22457 }
13629
13630 22452 void eBigDig::draw(BITMAP *dest)
13631 {
13632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if(anim!=aDIG)
13633 {
13634 update_enemy_frame();
13635 xofs-=8;
13636 yofs-=8;
13637 drawblock(dest,15);
13638 xofs+=8;
13639 yofs+=8;
13640 return;
13641 }
13642
13643 22452 tile = o_tile;
13644 22452 int32_t fdiv = frate/4;
13645
1/2
✓ Branch 0 taken 22452 times.
✗ Branch 1 not taken.
22452 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13646
13647
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13648 22452 efrate:((clk>=(frate>>1))?1:0);
13649
13650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if ( do_animation )
13651 {
13652
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 if(get_qr(qr_NEWENEMYTILES))
13653 {
13654
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
13655 {
13656 case up: //u
13657 1115 flip=0;
13658 1115 break;
13659
13660 case l_up: //d
13661 1221 flip=0;
13662 1221 tile+=8;
13663 1221 break;
13664
13665 case l_down: //l
13666 1344 flip=0;
13667 1344 tile+=40;
13668 1344 break;
13669
13670 case left: //r
13671 1195 flip=0;
13672 1195 tile+=48;
13673 1195 break;
13674
13675 case r_down: //ul
13676 1233 flip=0;
13677 1233 tile+=80;
13678 1233 break;
13679
13680 case down: //ur
13681 1223 flip=0;
13682 1223 tile+=88;
13683
13684 1223 break;
13685
13686 case r_up: //dl
13687 993 flip=0;
13688 993 tile+=120;
13689 993 break;
13690
13691 case right: //dr
13692 1450 flip=0;
13693 1450 tile+=128;
13694 1450 break;
13695 }
13696
13697 10238 tile+=(f2*2);
13698 10238 }
13699 else
13700 {
13701 12214 tile+=(f2)?0:2;
13702 12214 flip=(clk&1)?1:0;
13703 }
13704 22452 }
13705
13706 22452 xofs-=8;
13707 22452 yofs-=8;
13708 22452 drawblock(dest,15);
13709 22452 xofs+=8;
13710 22452 yofs+=8;
13711 22452 }
13712
13713 740 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13714 {
13715 740 int32_t wpnId = w->id;
13716
13717
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
740 if(wpnId==wWhistle && misc==0)
13718 44 misc=1;
13719
13720 740 return 0;
13721 }
13722
13723 /*
13724 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13725 {
13726 hxofs=hyofs=8;
13727 hzsz=16; //can't be jumped.
13728 clk2=70;
13729 misc=-1;
13730 mainguy=!getmapflag();
13731 }
13732
13733 bool eGanon::animate(int32_t index)
13734 {
13735 if(switch_hooked) return enemy::animate(index);
13736 if(dying)
13737
13738 return Dead(index);
13739
13740 if(clk==0)
13741 {
13742 removearmos(x,y,ffcactivated);
13743 }
13744
13745 switch(misc)
13746 {
13747 case -1:
13748 misc=0;
13749
13750 case 0:
13751 if(++clk2>72 && !(zc_oldrand()&3))
13752 {
13753 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13754 sfx(wpnsfx(wpn),pan(int32_t(x)));
13755 clk2=0;
13756 }
13757
13758 Stunclk=0;
13759 constant_walk(rate,homing,spw_none);
13760 break;
13761
13762 case 1:
13763 case 2:
13764 if(--Stunclk<=0)
13765 {
13766 int32_t r=zc_oldrand();
13767
13768 if(r&1)
13769 {
13770 y=96;
13771
13772 if(r&2)
13773 x=160;
13774 else
13775 x=48;
13776
13777 if(tooclose(x,y,48))
13778 x=208-x;
13779 }
13780
13781 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13782 //{
13783 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13784 // }
13785 // else
13786 // {
13787 loadpalset(csBOSS,pSprite(d->bosspal));
13788 // }
13789 misc=0;
13790 }
13791
13792 break;
13793
13794 case 3:
13795 {
13796 if(hclk>0)
13797 break;
13798
13799 misc=4;
13800 clk=0;
13801 hxofs=1000;
13802 loadpalset(9,pSprite(spPILE));
13803 music_stop();
13804 stop_sfx(WAV_ROAR);
13805
13806 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13807
13808 sfx(WAV_GANON);
13809 //Ganon's dustpile; fall in sideview. -Z
13810 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13811 dustpile->linked_parent = eeGANON;
13812 setmapflag();
13813 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13814 break;
13815 }
13816
13817 case 4:
13818 if(clk>=80)
13819 {
13820 misc=5;
13821
13822 if(getmapflag())
13823 {
13824 game->lvlitems[dlevel]|=liBOSS;
13825 //play_DmapMusic();
13826 playLevelMusic();
13827 return true;
13828 }
13829
13830 sfx(WAV_CLEARED);
13831 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13832 setmapflag();
13833 }
13834
13835 break;
13836 }
13837
13838 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13839 //{
13840 //if ( current_item_id(itype_amulet,false) >= 2 )
13841 //{
13842 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13843 //}
13844 //}
13845
13846
13847 return enemy::animate(index);
13848 }
13849
13850
13851 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13852 {
13853 //these are here to bypass compiler warnings about unused arguments
13854 int32_t wpnId = w->id;
13855 int32_t power = w->power;
13856 int32_t enemyHitWeapon = w->parentitem;
13857
13858 switch(misc)
13859 {
13860 case 0:
13861 {
13862 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13863 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13864 return 0;
13865
13866 //if we are not using the new defences, just reduce his HP
13867 if (!(editorflags & ENEMY_FLAG14))
13868 {
13869 hp-=power;
13870 if(hp>0)
13871 {
13872 misc=1;
13873 Stunclk=64;
13874 }
13875 else
13876 {
13877 loadpalset(csBOSS,pSprite(spBROWN));
13878 misc=2;
13879 Stunclk=284;
13880 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13881 }
13882
13883 sfx(WAV_EHIT,pan(int32_t(x)));
13884
13885 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13886
13887 return 1;
13888 }
13889 //otherwise, resolve his defence.
13890 else
13891 {
13892 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13893 if(hp>0)
13894 {
13895 misc=1;
13896 Stunclk=64;
13897 }
13898 else
13899 {
13900 loadpalset(csBOSS,pSprite(spBROWN));
13901 misc=2;
13902 Stunclk=284;
13903 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13904 }
13905
13906 sfx(WAV_EHIT,pan(int32_t(x)));
13907
13908 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13909
13910
13911 return 1;
13912 }
13913 }
13914 case 2:
13915 {
13916 if
13917 (
13918 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13919 || //or nothing specified, use silver arrows+
13920 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13921 )
13922 return 0;
13923 {
13924 misc=3;
13925 hclk=81;
13926 loadpalset(9,pSprite(spBROWN));
13927 return 1;
13928 }
13929
13930 }
13931 }
13932
13933 return 0;
13934 }
13935
13936 void eGanon::draw(BITMAP *dest)
13937 {
13938 switch(misc)
13939 {
13940 case 0:
13941 if((clk&3)==3)
13942 tile=(zc_oldrand()%5)*2+o_tile;
13943
13944 if(db!=999)
13945 break;
13946
13947 case 2:
13948 if(Stunclk<64 && (Stunclk&1) )
13949 {
13950 if
13951 (
13952 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13953 ||
13954 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13955 )
13956 {
13957 goto ganon_draw; //draw his weapons if we can see him
13958 }
13959 break;
13960 }
13961
13962 case -1:
13963 tile=o_tile;
13964
13965 //fall through
13966 case 1:
13967 case 3:
13968 ganon_draw:
13969 drawblock(dest,15);
13970 break;
13971
13972 case 4:
13973 draw_guts(dest);
13974 draw_flash(dest);
13975 break;
13976 }
13977
13978 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13979 {
13980 if
13981 (
13982 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13983 ||
13984 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13985 )
13986 {
13987 draw_guts(dest); //makes his shots visible, but not him
13988 draw_flash(dest);
13989 }
13990 }
13991 }
13992
13993 void eGanon::draw_guts(BITMAP *dest)
13994 {
13995 int32_t c = zc_min(clk>>3,8);
13996 tile = clk<24 ? 74 : 75;
13997 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13998 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13999 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14000 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14001 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14002 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14003 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14004 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14005 }
14006
14007 void eGanon::draw_flash(BITMAP *dest)
14008 {
14009
14010 int32_t c = clk-(clk>>2);
14011 cs = (frame&3)+6;
14012 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14013 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14014 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14015 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14016 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14017 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14018 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14019 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14020 }
14021 */
14022
14023 20 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14024 20 {
14025 10 hxofs=hyofs=8;
14026
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (editorflags & ENEMY_FLAG3)
14027 {
14028 hxofs = 4;
14029 hyofs = 4;
14030 hit_width = 24;
14031 hit_height = 24;
14032 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
14033 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
14034 }
14035 10 hzsz=16; //can't be jumped.
14036 10 clk2=70;
14037 10 misc=-1;
14038
4/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
20 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
14039 10 }
14040
14041 15877 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
14042 {
14043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15877 times.
15877 if(dying)
14044
14045 return Dead(index);
14046
14047
2/2
✓ Branch 0 taken 15814 times.
✓ Branch 1 taken 63 times.
15877 if(clk==0)
14048 {
14049 63 removearmos(x,y,ffcactivated);
14050 63 }
14051
14052
6/7
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11467 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 720 times.
✓ Branch 6 taken 7 times.
15877 switch(misc)
14053 {
14054 case -1:
14055 10 misc=0;
14056 [[fallthrough]];
14057 case 0:
14058
4/4
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 10850 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 156 times.
11477 if(++clk2>72 && !(zc_oldrand()&3))
14059 {
14060 156 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14061 156 sfx(wpnsfx(wpn),pan(int32_t(x)));
14062 156 clk2=0;
14063 156 }
14064
14065 11477 Stunclk=0;
14066 11477 constant_walk(rate,homing,spw_none);
14067 11477 break;
14068
14069 case 1:
14070 case 2:
14071
2/2
✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 34 times.
2935 if(--Stunclk<=0)
14072 {
14073 34 int32_t r=zc_oldrand();
14074
14075
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 14 times.
34 if(r&1)
14076 {
14077 14 y=96;
14078
14079
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if(r&2)
14080 6 x=160;
14081 else
14082 8 x=48;
14083
14084
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
14 if(tooclose(x,y,48))
14085 6 x=208-x;
14086 14 }
14087
14088 34 loadpalset(csBOSS,pSprite(d->bosspal));
14089 34 misc=0;
14090 34 }
14091
14092 2935 break;
14093
14094 case 3:
14095 {
14096
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 9 times.
738 if(hclk>0)
14097 729 break;
14098
14099 9 misc=4;
14100 9 clk=0;
14101 9 hxofs=1000;
14102 9 loadpalset(9,pSprite(spPILE));
14103 9 music_stop();
14104 9 stop_sfx(WAV_ROAR);
14105
14106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
14107
14108 9 sfx(WAV_GANON);
14109 //Ganon's dustpile; fall in sideview. -Z
14110 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
14111 //dustpile->miscellaneous[31] = eeGANON;
14112
6/12
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
9 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14113 9 item *dustpile = NULL;
14114 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
14115 9 dustpile = (item *)items.spr(items.Count() - 1);
14116 9 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
14117 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
14118 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14119 9 break;
14120 }
14121
14122 case 4:
14123
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 9 times.
720 if(clk>=80)
14124 {
14125 9 misc=5;
14126
14127 //game->lvlitems[dlevel]|=liBOSS;
14128
14129 9 sfx(WAV_CLEARED);
14130 //Add the big TF over the ashes!
14131
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for(word q = 0; q < items.Count(); q++)
14132 {
14133 18 item *ashes = (item*)items.spr(q);
14134
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
18 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
14135 {
14136 //Z_scripterrlog("Found correct dustpile!\n");
14137
4/8
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
9 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
14138 9 item *bigtriforce = NULL;
14139 9 bigtriforce = (item *)items.spr(items.Count() - 1);
14140 9 bigtriforce->linked_parent = eeGANON;
14141 9 }
14142 18 }
14143 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14144 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
14145 9 }
14146
14147 720 break;
14148 7 case 5: return true;
14149 }
14150
14151 15870 return enemy::animate(index);
14152 15877 }
14153
14154
14155 803 int32_t eGanon::takehit(weapon *w, weapon* realweap)
14156 {
14157 //these are here to bypass compiler warnings about unused arguments
14158 803 int32_t wpnId = w->id;
14159 803 int32_t power = w->power;
14160 803 int32_t enemyHitWeapon = w->parentitem;
14161
14162
3/3
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 125 times.
803 switch(misc)
14163 {
14164 case 0:
14165
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 43 times.
74 if(wpnId!=wSword)
14166 31 return 0;
14167
14168 43 hp-=power;
14169
14170
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 9 times.
43 if(hp>0)
14171 {
14172 34 misc=1;
14173 34 Stunclk=64;
14174 34 }
14175 else
14176 {
14177 9 loadpalset(csBOSS,pSprite(spBROWN));
14178 9 misc=2;
14179 9 Stunclk=284;
14180 9 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
14181 }
14182
14183 43 sfx(WAV_EHIT,pan(int32_t(x)));
14184
14185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
14186
14187 43 return 1;
14188
14189 case 2:
14190
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
125 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
14191 116 return 0;
14192
14193 9 misc=3;
14194 9 hclk=81;
14195 9 loadpalset(9,pSprite(spBROWN));
14196 9 return 1;
14197 }
14198
14199 604 return 0;
14200 803 }
14201
14202 17817 void eGanon::draw(BITMAP *dest)
14203 {
14204
6/6
✓ Branch 0 taken 2914 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 759 times.
✓ Branch 3 taken 1950 times.
✓ Branch 4 taken 11467 times.
✓ Branch 5 taken 720 times.
17817 switch(misc)
14205 {
14206 case 0:
14207
2/2
✓ Branch 0 taken 8601 times.
✓ Branch 1 taken 2866 times.
11467 if((clk&3)==3)
14208 2866 tile=(zc_oldrand()%5)*2+o_tile;
14209
14210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
14211 {
14212
14213 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14214 {
14215 int odraw = drawstyle;
14216 drawstyle = 2;
14217 drawblock(dest,15);
14218 drawstyle = odraw;
14219 }
14220 else
14221 {
14222 drawblock(dest,15);
14223 }
14224 break;
14225
14226 }
14227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
14228 {
14229 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14230 {
14231 int odraw = drawstyle;
14232 drawstyle = 2;
14233 drawblock(dest,15);
14234 drawstyle = odraw;
14235 }
14236 else
14237 {
14238 drawblock(dest,15);
14239 }
14240 break;
14241 }
14242
1/2
✓ Branch 0 taken 11467 times.
✗ Branch 1 not taken.
11467 if(db!=999)
14243 11467 break;
14244 [[fallthrough]];
14245 case 2:
14246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if(Stunclk<64 && (Stunclk&1))
14247 break;
14248 [[fallthrough]];
14249 case -1:
14250 2709 tile=o_tile;
14251
14252 [[fallthrough]];
14253 case 1:
14254 case 3:
14255 5623 drawblock(dest,15);
14256 5623 break;
14257
14258 case 4:
14259 720 draw_guts(dest);
14260 720 draw_flash(dest);
14261 720 break;
14262 }
14263 17817 }
14264
14265 720 void eGanon::draw_guts(BITMAP *dest)
14266 {
14267
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 153 times.
720 int32_t c = zc_min(clk>>3,8);
14268 720 tile = clk<24 ? 74 : 75;
14269 720 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14270 720 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14271 720 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14272 720 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14273 720 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14274 720 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14275 720 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14276 720 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14277 720 }
14278
14279 720 void eGanon::draw_flash(BITMAP *dest)
14280 {
14281
14282 720 int32_t c = clk-(clk>>2);
14283 720 cs = (frame&3)+6;
14284 720 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14285 720 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14286 720 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14287 720 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14288 720 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14289 720 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14290 720 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14291 720 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14292 720 }
14293
14294 8 void getBigTri(int32_t id2)
14295 {
14296 /*
14297 *************************
14298 * BIG TRIFORCE SEQUENCE *
14299 *************************
14300 0 BIGTRI out, WHITE flash in
14301 4 WHITE flash out, PILE cset white
14302 8 WHITE in
14303 ...
14304 188 WHITE out
14305 191 PILE cset red
14306 200 top SHUTTER opens
14307 209 bottom SHUTTER opens
14308 */
14309 8 sfx(itemsbuf[id2].playsound);
14310 8 guys.clear();
14311
14312
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
14313 {
14314 game->lvlitems[dlevel]|=liTRIFORCE;
14315 }
14316
14317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14318
14319 8 draw_screen(tmpscr);
14320
14321
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1536 times.
1544 for(int32_t f=0; f<24*8 && !Quit; f++)
14322 {
14323
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==4)
14324 {
14325
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 8 times.
128 for(int32_t i=1; i<16; i++)
14326 {
14327 120 RAMpal[CSET(9)+i]=_RGB(63,63,63);
14328 120 }
14329 8 }
14330
14331
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==0)
14332 {
14333
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t cs=2; cs<5; cs++)
14334 {
14335
2/2
✓ Branch 0 taken 8640 times.
✓ Branch 1 taken 576 times.
9216 for(int32_t i=1; i<16; i++)
14336 {
14337 8640 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
14338 8640 }
14339 576 }
14340
14341 192 refreshpal=true;
14342 192 }
14343
14344
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==4)
14345 {
14346
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14347 else loadlvlpal(0xB);
14348 192 }
14349
14350
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==191)
14351 {
14352 8 loadpalset(9,pSprite(spPILE));
14353 8 }
14354
14355 1536 advanceframe(true);
14356 1536 }
14357
14358 //play_DmapMusic();
14359 8 playLevelMusic();
14360
14361
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
14362 {
14363 Hero.dowarp(1,0); //side warp
14364 }
14365 8 }
14366
14367 /**********************************/
14368 /*** Multiple-Segment Enemies ***/
14369 /**********************************/
14370
14371
14372 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14373 188 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14374 188 {
14375
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if( !(editorflags & ENEMY_FLAG5) )
14376 {
14377
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x=128;
14378
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y=48;
14379 94 }
14380 //else { x = X; y = Y; }
14381
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 dir=(zc_oldrand()&7)+8;
14382 94 superman=1;
14383 94 fading=fade_invisible;
14384 94 hxofs=1000;
14385 94 segcnt=clk;
14386 94 segid=Id|0x1000;
14387 94 clk=0;
14388
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 id=guys.Count();
14389
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14390 94 tile=o_tile;
14391 94 hitdir = -1;
14392 94 stickclk = 0;
14393
14394 /*
14395 if (get_qr(qr_NEWENEMYTILES))
14396 {
14397 tile=nets+1220;
14398 }
14399 else
14400 {
14401 tile=57;
14402 }
14403 */
14404 94 }
14405
14406 86130 bool eMoldorm::animate(int32_t index)
14407 {
14408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(switch_hooked) return enemy::animate(index);
14409 86130 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14410
2/2
✓ Branch 0 taken 66843 times.
✓ Branch 1 taken 19287 times.
86130 if ( y > (max_y) )
14411 {
14412 19287 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14413 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14414 19287 }
14415
2/2
✓ Branch 0 taken 85736 times.
✓ Branch 1 taken 394 times.
86130 if ( stickclk > 45 )
14416 {
14417 394 stickclk = 0;
14418 394 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14419 394 }
14420
14421
14422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(clk==0)
14423 {
14424 86130 removearmos(x,y,ffcactivated);
14425 86130 }
14426
14427
2/2
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 84876 times.
86130 if(clk2)
14428 {
14429
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 66 times.
1254 if(--clk2 == 0)
14430 {
14431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(flags&guy_neverret)
14432 66 never_return(index);
14433
14434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14435 66 leave_item();
14436
14437 66 stop_bgsfx(index);
14438 66 return true;
14439 }
14440 1188 }
14441 else
14442 {
14443
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(stunclk>0)
14444 stunclk=0;
14445 84876 constant_walk_8_old(rate,homing,spw_floater);
14446
14447
14448 84876 misc=dir;
14449
14450 // If any higher-numbered segments were killed, segcnt can be too high,
14451 // leading to a crash
14452
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(index+segcnt>=guys.Count())
14453 segcnt=guys.Count()-index-1;
14454
14455
2/2
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 453901 times.
538777 for(int32_t i=index+1; i<index+segcnt+1; i++)
14456 {
14457 453901 enemy* segment=((enemy*)guys.spr(i));
14458
14459 // More validation - if segcnt was wrong, this may not
14460 // actually be a Moldorm segment
14461
1/2
✓ Branch 0 taken 453901 times.
✗ Branch 1 not taken.
453901 if(segment->id!=segid)
14462 {
14463 segcnt=i-index-1;
14464 break;
14465 }
14466
14467
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1)
14468 {
14469 84966 x=segment->x;
14470 84966 y=segment->y;
14471 84966 }
14472
14473 453901 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14474 //Script your own blasted segmented bosses!! -Z
14475 453901 segment->parent_script_UID = this->script_UID;
14476
4/4
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 369025 times.
✓ Branch 2 taken 12139 times.
✓ Branch 3 taken 72737 times.
453901 if((i==index+segcnt)&&(i!=index+1)) //tail
14477 {
14478 72737 segment->dummy_int[1]=2;
14479 72737 }
14480 else
14481 {
14482 381164 segment->dummy_int[1]=1;
14483 }
14484
14485
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1) //head
14486 {
14487 84966 segment->dummy_int[1]=0;
14488 84966 }
14489
14490
2/2
✓ Branch 0 taken 453501 times.
✓ Branch 1 taken 400 times.
453901 if(segment->hp <= 0)
14491 {
14492 400 int32_t offset=1;
14493
14494
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 618 times.
1018 for(int32_t j=i; j<index+segcnt; j++)
14495 {
14496 // Triple-check
14497
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if(((enemy*)guys.spr(j+1))->id!=segid)
14498 {
14499 segcnt=j-index+1; // Add 1 because of --segcnt below
14500 break;
14501 }
14502 618 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14503 618 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14504 618 }
14505
14506 400 segment->hclk=33;
14507 400 --segcnt;
14508 400 --i; // Recheck the same index in case multiple segments died at once
14509 400 }
14510 453901 }
14511
14512
2/2
✓ Branch 0 taken 84810 times.
✓ Branch 1 taken 66 times.
84876 if(segcnt==0)
14513 {
14514 66 clk2=19;
14515
14516 66 x=guys.spr(index+1)->x;
14517 66 y=guys.spr(index+1)->y;
14518 66 }
14519 }
14520
14521 86064 return false;
14522 86130 }
14523
14524 1060 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14525 1060 {
14526
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if( !(editorflags & ENEMY_FLAG5) )
14527 {
14528
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 x=128;
14529
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 y=48;
14530 530 }
14531
14532
3/6
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 530 times.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
530 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14533 530 hyofs=4;
14534 530 hit_width=hit_height=8;
14535 530 hxofs=1000;
14536 530 mainguy=count_enemy=false;
14537 530 parentclk = 0;
14538 530 bgsfx=-1;
14539 530 flags&=~guy_neverret;
14540 //deadsfx = WAV_EDEAD;
14541 530 isCore = false;
14542 530 }
14543
14544 460921 bool esMoldorm::animate(int32_t index)
14545 {
14546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(switch_hooked) return enemy::animate(index);
14547 // Shouldn't be possible, but better to be sure
14548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(index==0)
14549 dying=true;
14550
14551
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 453901 times.
460921 if(dying)
14552 {
14553
1/2
✓ Branch 0 taken 7020 times.
✗ Branch 1 not taken.
7020 if(!dmisc2)
14554 7020 item_set=0;
14555
14556 7020 return Dead(index);
14557 }
14558
14559
2/2
✓ Branch 0 taken 22038 times.
✓ Branch 1 taken 431863 times.
453901 if(clk>=0)
14560 {
14561 431863 hxofs=4;
14562 431863 step=((enemy*)guys.spr(index-1))->step;
14563
14564
2/2
✓ Branch 0 taken 32657 times.
✓ Branch 1 taken 399206 times.
431863 if(parentclk == 0)
14565 {
14566 32657 misc=dir;
14567 32657 dir=((enemy*)guys.spr(index-1))->misc;
14568 //do alignment, as in parent's animation :-/ -DD
14569 32657 x.doFloor();
14570 32657 y.doFloor();
14571 32657 }
14572
14573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(step)
14574 431863 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14575
14576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(!watch)
14577 {
14578 431863 sprite::move(step);
14579 431863 }
14580 431863 }
14581
14582 453901 return enemy::animate(index);
14583 460921 }
14584
14585 1735 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14586 {
14587
2/2
✓ Branch 0 taken 1588 times.
✓ Branch 1 taken 147 times.
1735 if(enemy::takehit(w,realweap))
14588 1588 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14589
14590 147 return 0;
14591 1735 }
14592
14593 462871 void esMoldorm::draw(BITMAP *dest)
14594 {
14595 462871 tile=o_tile;
14596 462871 int32_t fdiv = frate/4;
14597
1/2
✓ Branch 0 taken 462871 times.
✗ Branch 1 not taken.
462871 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14598
14599
2/2
✓ Branch 0 taken 385733 times.
✓ Branch 1 taken 77138 times.
462871 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14600 462871 efrate:((clk>=(frate>>1))?1:0);
14601
14602
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 385733 times.
462871 if(get_qr(qr_NEWENEMYTILES))
14603 {
14604 385733 tile+=dummy_int[1]*40;
14605
14606
2/2
✓ Branch 0 taken 17795 times.
✓ Branch 1 taken 367938 times.
385733 if(dir<8)
14607 {
14608 17795 flip=0;
14609
2/2
✓ Branch 0 taken 13667 times.
✓ Branch 1 taken 4128 times.
17795 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14610
14611
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 if(dir>3) // Skip to the next row for diagonals
14612 tile+=4;
14613 17795 }
14614 else
14615 {
14616
8/9
✓ Branch 0 taken 40703 times.
✓ Branch 1 taken 50522 times.
✓ Branch 2 taken 41128 times.
✓ Branch 3 taken 50152 times.
✓ Branch 4 taken 42370 times.
✓ Branch 5 taken 40742 times.
✓ Branch 6 taken 49191 times.
✓ Branch 7 taken 53130 times.
✗ Branch 8 not taken.
367938 switch(dir-8) //directions get screwed up after 8. *shrug*
14617 {
14618 case up: //u
14619 40703 flip=0;
14620 40703 break;
14621
14622 case l_up: //d
14623 50522 flip=0;
14624 50522 tile+=4;
14625 50522 break;
14626
14627 case l_down: //l
14628 41128 flip=0;
14629 41128 tile+=8;
14630 41128 break;
14631
14632 case left: //r
14633 50152 flip=0;
14634 50152 tile+=12;
14635 50152 break;
14636
14637 case r_down: //ul
14638 42370 flip=0;
14639 42370 tile+=20;
14640 42370 break;
14641
14642 case down: //ur
14643 40742 flip=0;
14644 40742 tile+=24;
14645 40742 break;
14646
14647 case r_up: //dl
14648 49191 flip=0;
14649 49191 tile+=28;
14650 49191 break;
14651
14652 case right: //dr
14653 53130 flip=0;
14654 53130 tile+=32;
14655 53130 break;
14656 }
14657 }
14658
14659 385733 tile+=f2;
14660 385733 }
14661
14662
2/2
✓ Branch 0 taken 22092 times.
✓ Branch 1 taken 440779 times.
462871 if(clk>=0)
14663 440779 enemy::draw(dest);
14664 462871 }
14665
14666 478 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14667 478 {
14668
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if( !(editorflags & ENEMY_FLAG5) )
14669 {
14670
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 x=64;
14671
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 y=80;
14672 239 }
14673 //else { x = X; y = Y; }
14674 //zprint2("lanmola index is %d\n", index);
14675 //byte legaldirs = 0;
14676 239 int32_t incr = 16;
14677 //int32_t possiiblepos = 0;
14678 //int32_t positions[8] = {0};
14679
14680 //Don't spawn in pits.
14681
5/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✓ Branch 7 taken 90 times.
239 if ( m_walkflag_simple(x, y) )
14682 {
14683 //zprint2("Can't spawn here.\n");
14684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 for ( ; incr < 240; incr += 16 )
14685 {
14686 //move if we spawn over a pit
14687 //check each direction
14688
7/12
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 124 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 124 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 120 times.
124 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14689 {
14690 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14691
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14692 }
14693
7/12
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 92 times.
120 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14694 {
14695 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14696
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 x+=incr; break;
14697 }
14698
9/16
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 92 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 60 times.
92 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14699 {
14700 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14701
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14702 }
14703
8/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
60 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14704 {
14705 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14706 x+=incr; y-=incr; break;
14707 }
14708
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14709 {
14710 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14711 y -= incr; break;
14712 }
14713
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14714 {
14715 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14716 y+=incr; break;
14717 }
14718
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14719 {
14720 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14721
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14722 }
14723
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14724 {
14725 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14726 x+=incr; y+=incr; break;
14727 }
14728 34 else continue;
14729
14730 }
14731
14732 90 }
14733
14734 239 dir=up;
14735 239 superman=1;
14736 239 fading=fade_invisible;
14737 239 hxofs=1000;
14738 239 segcnt=clk;
14739 239 clk=0;
14740 //set up move history
14741
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1691 times.
1930 for(int32_t i=0; i <= (1<<dmisc2); i++)
14742
3/6
✓ Branch 0 taken 1691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1691 times.
✗ Branch 5 not taken.
1691 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14743 239 }
14744
14745 134485 bool eLanmola::animate(int32_t index)
14746 {
14747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134485 times.
134485 if(switch_hooked) return enemy::animate(index);
14748
2/2
✓ Branch 0 taken 112061 times.
✓ Branch 1 taken 22424 times.
134485 if(clk==0)
14749 {
14750 22424 removearmos(x,y,ffcactivated);
14751 22424 }
14752
14753
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 132623 times.
134485 if(clk2)
14754 {
14755
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 98 times.
1862 if(--clk2 == 0)
14756 {
14757
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
98 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14758 78 leave_item();
14759
14760 98 stop_bgsfx(index);
14761 98 return true;
14762 }
14763
14764 1764 return false;
14765 }
14766
14767
14768 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14769 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14770 //I've added a complete movement history to this enemy to compensate -DD
14771 132623 constant_walk(rate,homing,spw_none);
14772 132623 prevState.pop_front();
14773 132623 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14774
14775 // This could cause a crash with Moldorms. I didn't see the same problem
14776 // with Lanmolas, but it looks like it ought to be possible, so here's
14777 // the same solution. - Saf
14778
1/2
✓ Branch 0 taken 132623 times.
✗ Branch 1 not taken.
132623 if(index+segcnt>=guys.Count())
14779 segcnt=guys.Count()-index-1;
14780
14781
2/2
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 599039 times.
731662 for(int32_t i=index+1; i<index+segcnt+1; i++)
14782 {
14783 599039 enemy* segment=((enemy*)guys.spr(i));
14784
14785 // More validation in case segcnt is wrong
14786
1/2
✓ Branch 0 taken 599039 times.
✗ Branch 1 not taken.
599039 if((segment->id&0xFFF)!=(id&0xFFF))
14787 {
14788 segcnt=i-index-1;
14789 break;
14790 }
14791
14792 599039 segment->o_tile=o_tile;
14793 599039 segment->parent_script_UID = this->script_UID;
14794
4/4
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 466416 times.
✓ Branch 2 taken 19514 times.
✓ Branch 3 taken 113109 times.
599039 if((i==index+segcnt)&&(i!=index+1))
14795 {
14796 113109 segment->dummy_int[1]=1; //tail
14797 113109 }
14798 else
14799 {
14800 485930 segment->dummy_int[1]=0;
14801 }
14802
14803
2/2
✓ Branch 0 taken 598467 times.
✓ Branch 1 taken 572 times.
599039 if(segment->hp <= 0)
14804 {
14805
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 977 times.
1549 for(int32_t j=i; j<index+segcnt; j++)
14806 {
14807 // Triple-check
14808
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14809 {
14810 segcnt=j-index+1; // Add 1 because of --segcnt below
14811 break;
14812 }
14813 977 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14814 977 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14815 977 }
14816
14817 572 ((enemy*)guys.spr(i))->hclk=33;
14818 572 --segcnt;
14819 572 --i; // Recheck the same index in case multiple segments died at once
14820 572 }
14821 599039 }
14822
14823
2/2
✓ Branch 0 taken 132525 times.
✓ Branch 1 taken 98 times.
132623 if(segcnt==0)
14824 {
14825 98 clk2=19;
14826 98 x=guys.spr(index+1)->x;
14827 98 y=guys.spr(index+1)->y;
14828 98 setmapflag(mTMPNORET);
14829 98 }
14830
14831 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14832 //which is... disastrous.
14833 132623 hp = 1;
14834 132623 return enemy::animate(index);
14835 134485 }
14836
14837 2500 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14838 2500 {
14839
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 if( !(editorflags & ENEMY_FLAG5) )
14840 {
14841
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 x=64;
14842
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 y=80;
14843 1250 }
14844 1250 int32_t incr = 16;
14845 //Don't spawn in pits.
14846
5/8
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 450 times.
1250 if ( m_walkflag_simple(x, y) )
14847 {
14848 //zprint2("Can't spawn here.\n");
14849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
620 for ( ; incr < 240; incr += 16 )
14850 {
14851 //move if we spawn over a pit
14852 //check each direction
14853
7/12
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 620 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 620 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 620 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 600 times.
620 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14854 {
14855 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14856
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14857 }
14858
7/12
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 140 times.
✓ Branch 11 taken 460 times.
600 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14859 {
14860 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14861
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 x+=incr; break;
14862 }
14863
9/16
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 460 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 460 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 300 times.
460 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14864 {
14865 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14866
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14867 }
14868
8/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 300 times.
300 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14869 {
14870 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14871 x+=incr; y-=incr; break;
14872 }
14873
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14874 {
14875 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14876 y -= incr; break;
14877 }
14878
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14879 {
14880 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14881 y+=incr; break;
14882 }
14883
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14884 {
14885 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14886
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14887 }
14888
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14889 {
14890 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14891 x+=incr; y+=incr; break;
14892 }
14893 170 else continue;
14894
14895 }
14896
14897 450 }
14898
14899 1250 hxofs=1000;
14900 1250 hit_width=8;
14901 1250 mainguy=false;
14902 1250 count_enemy=(id<0x2000)?true:false;
14903
14904 //set up move history
14905
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 8910 times.
10160 for(int32_t i=0; i <= (1<<dmisc2); i++)
14906
3/6
✓ Branch 0 taken 8910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8910 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8910 times.
✗ Branch 5 not taken.
8910 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14907
14908 1250 bgsfx = -1;
14909 1250 isCore = false;
14910 1250 flags&=~guy_neverret;
14911 1250 }
14912
14913 609335 bool esLanmola::animate(int32_t index)
14914 {
14915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609335 times.
609335 if(switch_hooked) return enemy::animate(index);
14916 // Shouldn't be possible, but who knows
14917
1/2
✓ Branch 0 taken 609335 times.
✗ Branch 1 not taken.
609335 if(index==0)
14918 dying=true;
14919
14920
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 599039 times.
609335 if(dying)
14921 {
14922 10296 xofs=0;
14923
14924
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 8496 times.
10296 if(!dmisc3)
14925 8496 item_set=0;
14926
14927 10296 return Dead(index);
14928 }
14929
14930
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 579729 times.
599039 if(clk>=0)
14931 {
14932 579729 hxofs=4;
14933
14934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579729 times.
579729 if(!watch)
14935 {
14936 579729 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14937 579729 prevState.pop_front();
14938 579729 prevState.push_back(newstate);
14939 579729 x = newstate.first.first;
14940 579729 y = newstate.first.second;
14941 579729 dir = newstate.second;
14942 579729 }
14943 579729 }
14944
14945 599039 return enemy::animate(index);
14946 609335 }
14947
14948 1513 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14949 {
14950
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 131 times.
1513 if(enemy::takehit(w,realweap))
14951 1382 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14952
14953 131 return 0;
14954 1513 }
14955
14956 610611 void esLanmola::draw(BITMAP *dest)
14957 {
14958 610611 tile=o_tile;
14959 610611 int32_t fdiv = frate/4;
14960
1/2
✓ Branch 0 taken 610611 times.
✗ Branch 1 not taken.
610611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14961
14962
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14963 610611 efrate:((clk>=(frate>>1))?1:0);
14964
14965
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 if(get_qr(qr_NEWENEMYTILES))
14966 {
14967
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
14968 {
14969 269264 tile+=20;
14970
14971
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
14972 {
14973 59482 tile+=20;
14974 59482 }
14975 269264 }
14976
14977
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
14978 {
14979 case up:
14980 70158 flip=0;
14981 70158 break;
14982
14983 case down:
14984 71956 flip=0;
14985 71956 tile+=4;
14986 71956 break;
14987
14988 case left:
14989 93557 flip=0;
14990 93557 tile+=8;
14991 93557 break;
14992
14993 case right:
14994 101862 flip=0;
14995 101862 tile+=12;
14996 101862 break;
14997 }
14998
14999 337533 tile+=f2;
15000 337533 }
15001 else
15002 {
15003
2/2
✓ Branch 0 taken 66631 times.
✓ Branch 1 taken 206447 times.
273078 if(id>=0x2000)
15004 {
15005 206447 tile+=1;
15006 206447 }
15007 }
15008
15009
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 591301 times.
610611 if(clk>=0)
15010 591301 enemy::draw(dest);
15011 610611 }
15012
15013 118 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
15014 118 {
15015 //these are here to bypass compiler warnings about unused arguments
15016 59 Clk=Clk;
15017 59 superman=1;
15018
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 dir=(zc_oldrand()&7)+8;
15019 59 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
15020
15021
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 59 times.
327 for(int32_t i=0; i<armcnt; i++)
15022 268 arm[i]=i;
15023
15024 59 fading=fade_blue_poof;
15025 //nets+4680;
15026 59 adjusted=false;
15027 59 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
15028
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15029 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15030 // al_trace("Enemy txsz:%i\n", txsz);
15031
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15033
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15035
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15036
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15037 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15038
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15040 {
15041 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15042 }
15043
15044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15045 59 }
15046
15047 30979 bool eManhandla::animate(int32_t index)
15048 {
15049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30979 times.
30979 if(switch_hooked) return enemy::animate(index);
15050
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 30209 times.
30979 if(dying)
15051 770 return Dead(index);
15052
15053
2/2
✓ Branch 0 taken 28958 times.
✓ Branch 1 taken 1251 times.
30209 if(clk==0)
15054 {
15055 1251 removearmos(x,y,ffcactivated);
15056 1251 }
15057
15058
15059 // check arm status, move dead ones to end of group
15060
2/2
✓ Branch 0 taken 94683 times.
✓ Branch 1 taken 30209 times.
124892 for(int32_t i=0; i<armcnt; i++)
15061 {
15062 94683 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
15063
3/4
✓ Branch 0 taken 94683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 94479 times.
94683 if(!cur_arm || cur_arm->dying)
15064 {
15065
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 204 times.
456 for(int32_t j=i; j<armcnt-1; j++)
15066 {
15067 252 zc_swap(arm[j],arm[j+1]);
15068 252 guys.swap(index+j+1,index+j+2);
15069 252 }
15070
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 36 times.
204 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
15071 {
15072 36 leave_item();
15073 36 }
15074 204 --armcnt;
15075 204 --i;
15076 204 continue;
15077 }
15078
2/2
✓ Branch 0 taken 94211 times.
✓ Branch 1 taken 268 times.
94479 if(!adjusted)
15079 {
15080
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 64 times.
268 if(!dmisc2)
15081 {
15082 204 cur_arm->o_tile=o_tile+40;
15083 204 cur_arm->parent_script_UID = this->script_UID;
15084 204 }
15085 else
15086 {
15087 64 cur_arm->o_tile=o_tile+160;
15088 64 cur_arm->parent_script_UID = this->script_UID;
15089 }
15090 268 }
15091 94479 }
15092
15093 30209 adjusted=true;
15094
15095 // move or die
15096
2/2
✓ Branch 0 taken 30166 times.
✓ Branch 1 taken 43 times.
30209 if(armcnt==0)
15097 43 hp=0;
15098 else
15099 {
15100 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
15101
1/2
✓ Branch 0 taken 30166 times.
✗ Branch 1 not taken.
30166 step=zc_min(zfix(4.5),(((!dmisc2)?4:8)-int64_t(armcnt))*0.5+zslongToFix(dstep*100));
15102 30166 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
15103
15104
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 if(!dmisc2)
15105 {
15106
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 27285 times.
107777 for(int32_t i=0; i<armcnt; i++)
15107 {
15108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15109 {
15110 case 0:
15111 18990 dy1=-24;
15112 18990 break;
15113
15114 case 1:
15115 21427 dy2=31;
15116 21427 break;
15117
15118 case 2:
15119 19973 dx1=-16;
15120 19973 break;
15121
15122 case 3:
15123 20102 dx2=31;
15124 20102 break;
15125 }
15126 80492 }
15127 27285 }
15128 else
15129 {
15130 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
15131
15132
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
15133 {
15134
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
15135 {
15136 case 0:
15137 4279 dy1=-32;
15138 4279 break;
15139
15140 case 1:
15141 3184 dy2=39;
15142 3184 break;
15143
15144 case 2:
15145 2549 dx1=-24;
15146 2549 break;
15147
15148 case 3:
15149 3975 dx2=39;
15150 3975 break;
15151 }
15152 13987 }
15153 }
15154
15155 30166 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
15156
15157
2/2
✓ Branch 0 taken 94479 times.
✓ Branch 1 taken 30166 times.
124645 for(int32_t i=0; i<armcnt; i++)
15158 {
15159 94479 zfix dx=(zfix)0,dy=(zfix)0;
15160
15161
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 13987 times.
94479 if(!dmisc2)
15162 {
15163
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15164 {
15165 case 0:
15166 18990 dy=-16;
15167 18990 break;
15168
15169 case 1:
15170 21427 dy=16;
15171 21427 break;
15172
15173 case 2:
15174 19973 dx=-16;
15175 19973 break;
15176
15177 case 3:
15178 20102 dx=16;
15179 20102 break;
15180 }
15181 80492 }
15182 else
15183 {
15184
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
15185 {
15186 case 0:
15187 1680 dy=-24;
15188 1680 dx=-8;
15189 1680 break;
15190
15191 case 1:
15192 1789 dy=24;
15193 1789 dx=8;
15194 1789 break;
15195
15196 case 2:
15197 1292 dx=-24;
15198 1292 dy=8;
15199 1292 break;
15200
15201 case 3:
15202 2015 dx=24;
15203 2015 dy=-8;
15204 2015 break;
15205
15206 case 4:
15207 2599 dy=-24;
15208 2599 dx=8;
15209 2599 break;
15210
15211 case 5:
15212 1395 dy=24;
15213 1395 dx=-8;
15214 1395 break;
15215
15216 case 6:
15217 1257 dx=-24;
15218 1257 dy=-8;
15219 1257 break;
15220
15221 case 7:
15222 1960 dx=24;
15223 1960 dy=8;
15224 1960 break;
15225 }
15226 }
15227
15228 94479 guys.spr(index+i+1)->x = x+dx;
15229 94479 guys.spr(index+i+1)->y = y+dy;
15230 94479 }
15231 }
15232
15233 30209 return enemy::animate(index);
15234 30979 }
15235
15236
15237 1338 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
15238 {
15239 1338 int32_t wpnId = w->id;
15240
15241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1338 times.
1338 if(dying)
15242 return 0;
15243
15244
3/4
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1338 switch(wpnId)
15245 {
15246 case wBomb:
15247 case wSBomb:
15248 case wSword:
15249 case wHammer:
15250 case wWand:
15251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
448 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15252
15253 case wLitBomb:
15254 case wLitSBomb:
15255 case wBait:
15256 case wWhistle:
15257 case wFire:
15258 case wWind:
15259 case wSSparkle:
15260 case wFSparkle:
15261 case wPhantom:
15262 1321 return 0;
15263
15264 case wHookshot:
15265 case wBrang:
15266 sfx(WAV_CHINK,pan(int32_t(x)));
15267 break;
15268
15269 default:
15270
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15271 else sfx(WAV_CHINK,pan(int32_t(x)));
15272
15273 17 }
15274
15275 17 return 1;
15276 1338 }
15277
15278 30977 void eManhandla::draw(BITMAP *dest)
15279 {
15280 30977 tile=o_tile;
15281 30977 int32_t fdiv = frate/4;
15282
1/2
✓ Branch 0 taken 30977 times.
✗ Branch 1 not taken.
30977 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15283
15284
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15285 30977 efrate:((clk>=(frate>>1))?1:0);
15286
15287
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 if(get_qr(qr_NEWENEMYTILES))
15288 {
15289
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 19500 times.
22018 if(!dmisc2)
15290 {
15291
8/9
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 2274 times.
✓ Branch 2 taken 2799 times.
✓ Branch 3 taken 2974 times.
✓ Branch 4 taken 1879 times.
✓ Branch 5 taken 1895 times.
✓ Branch 6 taken 2025 times.
✓ Branch 7 taken 3189 times.
✗ Branch 8 not taken.
19500 switch(dir-8) //directions get screwed up after 8. *shrug*
15292 {
15293 case up: //u
15294 2465 flip=0;
15295 2465 break;
15296
15297 case l_up: //d
15298 2274 flip=0;
15299 2274 tile+=4;
15300 2274 break;
15301
15302 case l_down: //l
15303 2799 flip=0;
15304 2799 tile+=8;
15305 2799 break;
15306
15307 case left: //r
15308 2974 flip=0;
15309 2974 tile+=12;
15310 2974 break;
15311
15312 case r_down: //ul
15313 1879 flip=0;
15314 1879 tile+=20;
15315 1879 break;
15316
15317 case down: //ur
15318 1895 flip=0;
15319 1895 tile+=24;
15320 1895 break;
15321
15322 case r_up: //dl
15323 2025 flip=0;
15324 2025 tile+=28;
15325 2025 break;
15326
15327 case right: //dr
15328 3189 flip=0;
15329 3189 tile+=32;
15330 3189 break;
15331 }
15332
15333 19500 tile+=f2;
15334 19500 enemy::draw(dest);
15335 19500 } //manhandla 2, big body
15336 else
15337 {
15338
15339
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
15340 {
15341 case up: //u
15342 357 flip=0;
15343 357 break;
15344
15345 case l_up: //d
15346 483 flip=0;
15347 483 tile+=8;
15348 483 break;
15349
15350 case l_down: //l
15351 500 flip=0;
15352 500 tile+=40;
15353 500 break;
15354
15355 case left: //r
15356 315 flip=0;
15357 315 tile+=48;
15358 315 break;
15359
15360 case r_down: //ul
15361 196 flip=0;
15362 196 tile+=80;
15363 196 break;
15364
15365 case down: //ur
15366 215 flip=0;
15367 215 tile+=88;
15368 215 break;
15369
15370 case r_up: //dl
15371 164 flip=0;
15372 164 tile+=120;
15373 164 break;
15374
15375 case right: //dr
15376 288 flip=0;
15377 288 tile+=128;
15378 288 break;
15379 }
15380
15381 2518 tile+=(f2*2);
15382 2518 xofs-=8;
15383 2518 yofs-=8;
15384 2518 drawblock(dest,15);
15385 2518 xofs+=8;
15386 2518 yofs+=8;
15387 }
15388 22018 }
15389 else
15390 {
15391
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
15392 {
15393 8444 enemy::draw(dest);
15394 8444 }
15395 else
15396 {
15397 515 xofs-=8;
15398 515 yofs-=8;
15399 515 enemy::draw(dest);
15400 515 xofs+=16;
15401 515 enemy::draw(dest);
15402 515 yofs+=16;
15403 515 enemy::draw(dest);
15404 515 xofs-=16;
15405 515 enemy::draw(dest);
15406 515 xofs+=8;
15407 515 yofs-=8;
15408 }
15409 }
15410 30977 }
15411
15412 536 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15413 536 {
15414 268 id=misc=clk;
15415 268 dir = clk & 3;
15416 268 clk=0;
15417 268 mainguy=count_enemy=false;
15418 268 dummy_bool[0]=false;
15419 268 item_set=0;
15420 268 bgsfx=-1;
15421 268 deadsfx = WAV_EDEAD;
15422 268 flags &= (~guy_neverret);
15423 268 isCore = false;
15424 //Probably will be buggy. -Z 12 AUG 2020
15425 268 SIZEflags = d->SIZEflags;
15426
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15427 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15428 // al_trace("Enemy txsz:%i\n", txsz);
15429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15433
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15434
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15435 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15436
1/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15438 {
15439 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15440 }
15441
15442
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15443 268 }
15444
15445 98135 bool esManhandla::animate(int32_t index)
15446 {
15447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98135 times.
98135 if(switch_hooked) return enemy::animate(index);
15448
2/2
✓ Branch 0 taken 3656 times.
✓ Branch 1 taken 94479 times.
98135 if(dying)
15449 3656 return Dead(index);
15450
15451
2/2
✓ Branch 0 taken 6029 times.
✓ Branch 1 taken 88450 times.
94479 if(clk==0)
15452 {
15453 6029 removearmos(x,y,ffcactivated);
15454 6029 }
15455
15456
2/2
✓ Branch 0 taken 80858 times.
✓ Branch 1 taken 13621 times.
94479 if(--clk2<=0)
15457 {
15458 13621 clk2=unsigned(zc_oldrand())%5+5;
15459 13621 clk3^=1;
15460 13621 }
15461
15462
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 93728 times.
94479 if(!(zc_oldrand()&127))
15463 {
15464 751 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15465 751 sfx(wpnsfx(wpn),pan(int32_t(x)));
15466 751 }
15467
15468 94479 return enemy::animate(index);
15469 98135 }
15470
15471 98127 void esManhandla::draw(BITMAP *dest)
15472 {
15473 98127 tile=o_tile;
15474 98127 int32_t fdiv = frate/4;
15475
1/2
✓ Branch 0 taken 98127 times.
✗ Branch 1 not taken.
98127 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15476
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15477 98127 efrate:((clk>=(frate>>1))?1:0);
15478
15479
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 if(get_qr(qr_NEWENEMYTILES))
15480 {
15481
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17260 times.
✓ Branch 2 taken 19375 times.
✓ Branch 3 taken 18024 times.
✓ Branch 4 taken 18287 times.
72946 switch(misc&3)
15482 {
15483 case up:
15484 17260 break;
15485
15486 case down:
15487 19375 tile+=4;
15488 19375 break;
15489
15490 case left:
15491 18024 tile+=8;
15492 18024 break;
15493
15494 case right:
15495 18287 tile+=12;
15496 18287 break;
15497 }
15498
15499 72946 tile+=f2;
15500 72946 }
15501 else
15502 {
15503
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6921 times.
✓ Branch 2 taken 5410 times.
✓ Branch 3 taken 6148 times.
✓ Branch 4 taken 6702 times.
25181 switch(misc&3)
15504 {
15505 case down:
15506 6148 flip=2;
15507
15508 [[fallthrough]];
15509 case up:
15510 13069 tile=(clk3)?188:189;
15511 13069 break;
15512
15513 case right:
15514 6702 flip=1;
15515 [[fallthrough]];
15516
15517 case left:
15518 12112 tile=(clk3)?186:187;
15519 12112 break;
15520 }
15521 }
15522
15523 98127 enemy::draw(dest);
15524 98127 }
15525
15526 188 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15527 188 {
15528
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( !(editorflags & ENEMY_FLAG5) )
15529 {
15530
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x = 120;
15531
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y = 48;
15532 94 }
15533 else
15534 {
15535 if ( !(editorflags & ENEMY_FLAG6) )
15536 {
15537 x = X; y = Y;
15538 }
15539 else
15540 {
15541 x = X+8; y = Y;
15542 }
15543 }
15544 94 hzsz = 32; // can't be jumped.
15545 94 flameclk=0;
15546 94 misc=clk; // total head count
15547 94 clk3=clk; // live head count
15548 94 clk=0;
15549 94 clk2=60; // fire ball clock
15550 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15551
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15552 94 dir = down;
15553 94 hxofs=4;
15554 94 hit_width=8;
15555 // frate=17*4;
15556 94 fading=fade_blue_poof;
15557 //nets+5420;
15558
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 23 times.
94 if(get_qr(qr_NEWENEMYTILES))
15559 {
15560 /*
15561 necktile=o_tile+8;
15562 if (dmisc3)
15563 {
15564 necktile+=8;
15565 }
15566 */
15567 71 necktile=o_tile+dmisc6;
15568 71 }
15569 else
15570 {
15571 23 necktile=s_tile;
15572 }
15573 94 }
15574
15575 70509 bool eGleeok::animate(int32_t index)
15576 {
15577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70509 times.
70509 if(switch_hooked) return enemy::animate(index);
15578
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69261 times.
70509 if(dying)
15579 1248 return Dead(index);
15580
15581
2/2
✓ Branch 0 taken 68945 times.
✓ Branch 1 taken 316 times.
69261 if(clk==0)
15582 {
15583 316 removearmos(x,y,ffcactivated);
15584 316 }
15585
15586 // Check if a head was killed somehow...
15587
2/2
✓ Branch 0 taken 35220 times.
✓ Branch 1 taken 34041 times.
69261 if(index+1+clk3>=guys.Count())
15588 34041 clk3=guys.Count()-index-1;
15589
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 55457 times.
69261 if(index+1+misc>=guys.Count())
15590 55457 misc=guys.Count()-index-1;
15591
15592 //fix for the "kill all enemies" item
15593
2/2
✓ Branch 0 taken 69255 times.
✓ Branch 1 taken 6 times.
69261 if(hp==-1000)
15594 {
15595
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15596 {
15597 // I haven't seen this fail, but it seems like it ought to be
15598 // possible, so I'm checking for it. - Saf
15599
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15600 break;
15601 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15602 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15603 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15604 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15605 12 }
15606
15607 6 clk3=0;
15608
15609
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15610 {
15611
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15612 break;
15613 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15614 12 }
15615 6 }
15616
15617
2/2
✓ Branch 0 taken 157172 times.
✓ Branch 1 taken 69261 times.
226433 for(int32_t i=0; i<clk3; i++)
15618 {
15619 157172 enemy *head = ((enemy*)guys.spr(index+i+1));
15620 157172 head->dummy_int[1]=necktile;
15621 157172 head->parent_script_UID = this->script_UID;
15622
15623
2/2
✓ Branch 0 taken 103123 times.
✓ Branch 1 taken 54049 times.
157172 if(get_qr(qr_NEWENEMYTILES))
15624 {
15625 103123 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15626 103123 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15627 103123 }
15628 else
15629 {
15630 54049 head->dummy_int[2]=necktile+1; //connected head tile
15631 54049 head->dummy_int[3]=necktile+2; //flying head tile
15632 }
15633
15634 157172 head->dmisc5=dmisc5; //neck segments
15635
15636 /*
15637 if (dmisc3)
15638 {
15639 head->dummy_bool[0]=true;
15640 }
15641 */
15642
2/2
✓ Branch 0 taken 154379 times.
✓ Branch 1 taken 2793 times.
157172 if(head->hclk)
15643 {
15644
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 569 times.
2793 if(hclk==0)
15645 {
15646 569 hp -= 1000 - head->hp;
15647 569 hclk = 33;
15648
15649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
569 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15650
15651 569 sfx(WAV_EHIT,pan(int32_t(head->x)));
15652 569 }
15653
15654 2793 head->hclk = 0;
15655 2793 }
15656
15657 // Must be set in case of naughty ZScripts
15658 157172 head->hp = 1000;
15659 157172 }
15660
15661
2/2
✓ Branch 0 taken 69069 times.
✓ Branch 1 taken 192 times.
69261 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
15662 {
15663 192 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15664 192 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
15665 192 }
15666
15667
2/2
✓ Branch 0 taken 19312 times.
✓ Branch 1 taken 49949 times.
69261 if(!dmisc3)
15668 {
15669
4/4
✓ Branch 0 taken 2801 times.
✓ Branch 1 taken 47148 times.
✓ Branch 2 taken 674 times.
✓ Branch 3 taken 2127 times.
49949 if(++clk2>72 && !(zc_oldrand()&3))
15670 {
15671 674 int32_t i=zc_oldrand()%misc;
15672 674 enemy *head = ((enemy*)guys.spr(index+i+1));
15673 674 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15674 674 sfx(wpnsfx(wpn),pan(int32_t(x)));
15675 674 clk2=0;
15676 674 }
15677 49949 }
15678 else
15679 {
15680
4/4
✓ Branch 0 taken 827 times.
✓ Branch 1 taken 18485 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 189 times.
19312 if(++clk2>100 && !(zc_oldrand()&3))
15681 {
15682 189 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15683 189 head->timer=zc_oldrand()%50+50;
15684 189 clk2=0;
15685 189 }
15686 }
15687
15688
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 69191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
69261 if((hp<=0 && !immortal))
15689 {
15690
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 70 times.
256 for(int32_t i=0; i<misc; i++)
15691 186 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15692
15693
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 67 times.
70 if(flags&guy_neverret) never_return(index);
15694 70 }
15695
15696 69261 return enemy::animate(index);
15697 70509 }
15698
15699 155 int32_t eGleeok::takehit(weapon*,weapon*)
15700 {
15701 155 return 0;
15702 }
15703
15704 70829 void eGleeok::draw(BITMAP *dest)
15705 {
15706 70829 tile=o_tile;
15707
15708
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69581 times.
70829 if(dying)
15709 {
15710 1248 enemy::draw(dest);
15711 1248 return;
15712 }
15713
15714 69581 int32_t f=clk/17;
15715
15716
2/2
✓ Branch 0 taken 46906 times.
✓ Branch 1 taken 22675 times.
69581 if(get_qr(qr_NEWENEMYTILES))
15717 {
15718 // body
15719 46906 xofs=-8;
15720 46906 yofs=32;
15721
15722
4/4
✓ Branch 0 taken 35926 times.
✓ Branch 1 taken 3851 times.
✓ Branch 2 taken 3602 times.
✓ Branch 3 taken 3527 times.
46906 switch(f)
15723
15724 {
15725 case 0:
15726 3851 tile+=0;
15727 3851 break;
15728
15729 case 1:
15730 3602 tile+=2;
15731 3602 break;
15732
15733 case 2:
15734 3527 tile+=4;
15735 3527 break;
15736
15737 default:
15738 35926 tile+=6;
15739 35926 break;
15740 }
15741 46906 }
15742 else
15743 {
15744 // body
15745 22675 xofs=-8;
15746 22675 yofs=32;
15747
15748
3/3
✓ Branch 0 taken 19415 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 1615 times.
22675 switch(f)
15749 {
15750 case 0:
15751 1645 tile+=0;
15752 1645 break;
15753
15754 case 2:
15755 1615 tile+=4;
15756 1615 break;
15757
15758 default:
15759 19415 tile+=2;
15760 19415 break;
15761 }
15762 }
15763
15764 69581 enemy::drawblock(dest,15);
15765 70829 }
15766
15767 70829 void eGleeok::draw2(BITMAP *dest)
15768 {
15769 // the neck stub
15770 70829 tile=necktile;
15771 70829 xofs=0;
15772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70829 times.
70829 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15773
15774
2/2
✓ Branch 0 taken 23071 times.
✓ Branch 1 taken 47758 times.
70829 if(get_qr(qr_NEWENEMYTILES))
15775 {
15776 47758 tile+=((clk&24)>>3);
15777 47758 }
15778
15779
3/4
✓ Branch 0 taken 69581 times.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69581 times.
70829 if(hp > 0 && !dont_draw())
15780 {
15781
4/4
✓ Branch 0 taken 1374 times.
✓ Branch 1 taken 68207 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 637 times.
69581 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15782 737 sprite::drawcloaked(dest);
15783 else
15784 68844 sprite::draw(dest);
15785 69581 }
15786 70829 }
15787
15788
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
804 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15789 536 {
15790
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 xoffset=0;
15791
2/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yoffset=(zfix)((dmisc5*4+2));
15792 // dummy_bool[0]=false;
15793 268 timer=0;
15794 /* fixing */
15795 268 hp=1000;
15796
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 step=1;
15797 268 item_set=0;
15798 //x=120; y=70;
15799
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 x = xoffset+parent->x;
15800
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 y = yoffset+parent->y;
15801 268 hxofs=4;
15802 268 hit_width=8;
15803
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15804 268 clk2=clk; // how int32_t to wait before moving first time
15805 268 clk=0;
15806 268 mainguy=count_enemy=false;
15807
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dir=zc_oldrand();
15808 268 clk3=((dir&2)>>1)+2; // left or right
15809 268 dir&=1; // up or down
15810
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dmisc5=vbound(dmisc5,1,255);
15811 268 isCore = false;
15812
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 parentCore = parent->getUID();
15813
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 268 times.
1340 for(int32_t i=0; i<dmisc5; i++)
15814 {
15815 1072 nxoffset[i] = 0;
15816 1072 nyoffset[i] = 0;
15817
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15818
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15819 1072 }
15820
15821 268 necktile=0;
15822 //TODO compatibility? -DD
15823 /*
15824 for(int32_t i=0; i<4; i++)
15825 {
15826 nx[i]=124;
15827 ny[i]=i*6+48;
15828 }*/
15829 268 bgsfx=-1;
15830 //no need for deadsfx
15831 268 }
15832
15833 202199 bool esGleeok::animate(int32_t index)
15834 {
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202199 times.
202199 if(switch_hooked) return enemy::animate(index);
15836 // don't call removearmos() - it's a segment.
15837
15838 202199 dmisc5=vbound(dmisc5,1,255);
15839
15840
2/2
✓ Branch 0 taken 45213 times.
✓ Branch 1 taken 156986 times.
202199 if(misc == 0)
15841 {
15842 156986 x = (xoffset+parent->x);
15843 156986 y = (yoffset+parent->y);
15844
15845
2/2
✓ Branch 0 taken 627944 times.
✓ Branch 1 taken 156986 times.
784930 for(int32_t i=0; i<dmisc5; i++)
15846 {
15847 627944 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15848 627944 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15849 627944 }
15850 156986 }
15851
15852 // set up the head tiles
15853 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15854 /*
15855 if (dummy_bool[0]) //if this is a flame gleeok
15856 {
15857 headtile+=180;
15858 }
15859 */
15860 202199 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15861 202199 flyingheadtile=dummy_int[3];
15862
15863 // set up the neck tiles
15864 202199 necktile=dummy_int[1];
15865
15866
2/2
✓ Branch 0 taken 74462 times.
✓ Branch 1 taken 127737 times.
202199 if(get_qr(qr_NEWENEMYTILES))
15867 {
15868 127737 necktile+=((clk&24)>>3);
15869 127737 }
15870
15871 /*
15872 else
15873 {
15874 necktile=145;
15875 }
15876 */
15877 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15878
15879
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 156986 times.
✓ Branch 2 taken 44881 times.
✓ Branch 3 taken 134 times.
✓ Branch 4 taken 198 times.
202199 switch(misc)
15880 {
15881 case 0: // live head
15882 // set up the attached head tiles
15883 156986 tile=headtile;
15884
15885
2/2
✓ Branch 0 taken 53978 times.
✓ Branch 1 taken 103008 times.
156986 if(get_qr(qr_NEWENEMYTILES))
15886 {
15887 103008 tile+=((clk&24)>>3);
15888 /*
15889 if (dummy_bool[0]) {
15890 tile+=1561;
15891 }
15892 */
15893 103008 }
15894
15895 /*
15896 else
15897 {
15898 tile=146;
15899 }
15900 */
15901
4/4
✓ Branch 0 taken 40101 times.
✓ Branch 1 taken 116885 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 35617 times.
156986 if(++clk2>=0 && !(clk2&3))
15902 {
15903
2/2
✓ Branch 0 taken 34833 times.
✓ Branch 1 taken 784 times.
35617 if(y<= (int32_t)parent->y + 8) dir=down;
15904
15905
2/2
✓ Branch 0 taken 34879 times.
✓ Branch 1 taken 738 times.
35617 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15906
15907
4/4
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 31889 times.
✓ Branch 2 taken 3626 times.
✓ Branch 3 taken 102 times.
35617 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15908 {
15909 102 dir^=1;
15910 102 }
15911
15912 35617 zfix tempx = x;
15913 35617 zfix tempy = y;
15914
15915 35617 sprite::move(step);
15916 35617 xoffset += (x-tempx);
15917 35617 yoffset += (y-tempy);
15918
15919
2/2
✓ Branch 0 taken 1490 times.
✓ Branch 1 taken 34127 times.
35617 if(clk2>=4)
15920 {
15921 1490 clk3^=1;
15922 1490 clk2=-4;
15923 1490 }
15924 else
15925 {
15926
2/2
✓ Branch 0 taken 33778 times.
✓ Branch 1 taken 349 times.
34127 if(x <= (int32_t)parent->x-(dmisc5*6))
15927 {
15928 349 clk3=right;
15929 349 }
15930
15931
2/2
✓ Branch 0 taken 33743 times.
✓ Branch 1 taken 384 times.
34127 if(x >= (int32_t)parent->x+(dmisc5*6))
15932 {
15933 384 clk3=left;
15934 384 }
15935
15936
4/4
✓ Branch 0 taken 23003 times.
✓ Branch 1 taken 11124 times.
✓ Branch 2 taken 21599 times.
✓ Branch 3 taken 1404 times.
34127 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15937 {
15938 1404 clk3^=1; // x jig
15939 1404 }
15940 else
15941 {
15942
4/4
✓ Branch 0 taken 11258 times.
✓ Branch 1 taken 21465 times.
✓ Branch 2 taken 10924 times.
✓ Branch 3 taken 334 times.
32723 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15943 {
15944 334 clk3^=1; // x switch back
15945 334 }
15946
15947 32723 clk2=-4;
15948 }
15949 }
15950
15951 35617 zc_swap(dir,clk3);
15952 35617 tempx = x;
15953 35617 tempy = y;
15954 35617 sprite::move(step);
15955 35617 xoffset += (x-tempx);
15956 35617 yoffset += (y-tempy);
15957 35617 zc_swap(dir,clk3);
15958
15959
2/2
✓ Branch 0 taken 106851 times.
✓ Branch 1 taken 35617 times.
142468 for(int32_t i=1; i<dmisc5; i++)
15960 {
15961 106851 nxoffset[i] = (zc_oldrand()%3);
15962 106851 nyoffset[i] = (zc_oldrand()%3);
15963 106851 }
15964 35617 }
15965
15966 156986 break;
15967
15968 case 1: // flying head
15969
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 42075 times.
44881 if(clk>=0)
15970
15971 {
15972 42075 variable_walk_8(rate,homing,hrate,spw_floater);
15973 42075 }
15974
15975 44881 break;
15976
15977 // the following are messages sent from the main guy...
15978 case -1: // got chopped off
15979 {
15980 134 misc=1;
15981 134 superman=1;
15982 134 hxofs=xofs=0;
15983 134 hit_width=16;
15984 134 cs=8;
15985 134 clk=-24;
15986 134 clk2=40;
15987 134 dir=(zc_oldrand()&7)+8;
15988 134 step=8.0/9.0;
15989 }
15990 134 break;
15991
15992 case -2: // the big guy is dead
15993 198 return true;
15994 }
15995
15996
2/2
✓ Branch 0 taken 189247 times.
✓ Branch 1 taken 12754 times.
202001 if(timer)
15997 {
15998
2/2
✓ Branch 0 taken 11233 times.
✓ Branch 1 taken 1521 times.
12754 if(!(timer%8))
15999 {
16000 1521 FireBreath(true);
16001 1521 }
16002
16003 12754 --timer;
16004 12754 }
16005
16006 202001 return enemy::animate(index);
16007 202199 }
16008
16009 3434 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
16010 {
16011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3434 if ((editorflags & ENEMY_FLAG7) && misc == 1)
16012 {
16013 int32_t wpnId = w->id;
16014
16015 if(dying)
16016 return 0;
16017
16018 switch(wpnId)
16019 {
16020 case wLitBomb:
16021 case wLitSBomb:
16022 case wBait:
16023 case wWhistle:
16024 case wFire:
16025 case wWind:
16026 case wSSparkle:
16027 case wFSparkle:
16028 case wPhantom:
16029 return 0;
16030
16031 case wHookshot:
16032 case wBrang:
16033 case wBeam:
16034 case wArrow:
16035 case wMagic:
16036 case wBomb:
16037 case wSBomb:
16038 sfx(WAV_CHINK,pan(int32_t(x)));
16039 break;
16040 default:
16041 break;
16042 }
16043
16044 return 1;
16045 }
16046 else
16047 {
16048 3434 int32_t ret = enemy::takehit(w,realweap);
16049
16050
2/2
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 2793 times.
3434 if(ret==-1)
16051 2793 return 2; // force it to wait a frame before checking sword attacks again
16052
16053 641 return ret;
16054 }
16055 3434 }
16056
16057 202887 void esGleeok::draw(BITMAP *dest)
16058 {
16059 202887 dmisc5=vbound(dmisc5,1,255);
16060
16061
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 157884 times.
✓ Branch 2 taken 45003 times.
202887 switch(misc)
16062 {
16063 case 0: //neck
16064
1/2
✓ Branch 0 taken 157884 times.
✗ Branch 1 not taken.
157884 if(!dont_draw())
16065 {
16066
2/2
✓ Branch 0 taken 473652 times.
✓ Branch 1 taken 157884 times.
631536 for(int32_t i=1; i<dmisc5; i++) //draw the neck
16067 {
16068
2/2
✓ Branch 0 taken 311511 times.
✓ Branch 1 taken 162141 times.
473652 if(get_qr(qr_NEWENEMYTILES))
16069 {
16070
3/4
✓ Branch 0 taken 2211 times.
✓ Branch 1 taken 309300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2211 times.
311511 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16071 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
16072 else
16073 309300 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
16074 311511 }
16075 else
16076 {
16077
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 157863 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
162141 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16078 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
16079 else
16080 162141 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
16081 }
16082 473652 }
16083 157884 }
16084
16085 157884 break;
16086
16087 case 1: //flying head
16088 45003 tile=flyingheadtile;
16089
16090
2/2
✓ Branch 0 taken 24590 times.
✓ Branch 1 taken 20413 times.
45003 if(get_qr(qr_NEWENEMYTILES))
16091 {
16092 24590 tile+=((clk&24)>>3);
16093 24590 break;
16094 }
16095
16096 /*
16097 else
16098 {
16099 tile=(clk&1)?147:148;
16100 break;
16101 }
16102 */
16103 20413 }
16104 202887 }
16105
16106 202887 void esGleeok::draw2(BITMAP *dest)
16107 {
16108 202887 enemy::draw(dest);
16109 202887 }
16110
16111 106 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
16112 106 {
16113
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( !(editorflags & ENEMY_FLAG5) )
16114 {
16115
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 x = 128;
16116
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 y = 48;
16117 53 }
16118 else { x = X; y = Y; }
16119 53 adjusted=false;
16120
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 dir=(zc_oldrand()&7)+8;
16121 //step=0.25;
16122 53 flycnt=dmisc1;
16123 53 flycnt2=dmisc2;
16124 53 loopcnt=0;
16125 53 clk4 = 0;
16126 53 clk5 = 0;
16127 53 clk6 = 0;
16128 53 clk7 = 0;
16129
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16130 53 SIZEflags = d->SIZEflags;
16131
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16132
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16133 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16134 // al_trace("Enemy txsz:%i\n", txsz);
16135
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
16136
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
16138
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hit_width = 32;
16139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
16140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
16141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
16142
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hxofs = -8;
16143
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
16144 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16145
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
16146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 else if (dmisc10 == 1) xofs = -8;
16147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16148 {
16149 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16150 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
16151 }
16152
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
53 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
16153
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (editorflags & ENEMY_FLAG8) misc = 1;
16154
16155
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
16156
16157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc29 == 0)
16158 {
16159
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16160 {
16161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc29 = (90 / 3);
16162 33 else dmisc29 = (84 / 3);
16163 33 }
16164 else
16165 {
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc29 = (90 / 2);
16167 20 else dmisc29 = (84 / 2);
16168 }
16169 53 }
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc30 == 0)
16171 {
16172
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16173 {
16174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc30 = (90 / 3)*0.5;
16175 33 else dmisc30 = (84 / 3)*0.5;
16176 33 }
16177 else
16178 {
16179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc30 = (90 / 2)*0.5;
16180 20 else dmisc30 = (84 / 2)*0.5;
16181 }
16182 53 }
16183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc31 == 0)
16184 {
16185
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16186 {
16187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc31 = (90 / 3)*2;
16188 33 else dmisc31 = (84 / 3)*2;
16189 33 }
16190 else
16191 {
16192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc31 = (90 / 2)*0.5;
16193 20 else dmisc31 = (84 / 2)*0.5;
16194 }
16195 53 }
16196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc32 == 0)
16197 {
16198
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16199 {
16200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc32 = (90 / 3);
16201 33 else dmisc32 = (84 / 3);
16202 33 }
16203 else
16204 {
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc32 = (90 / 2)*0.25;
16206 20 else dmisc32 = (84 / 2)*0.25;
16207 }
16208 53 }
16209 53 }
16210
16211 62362 bool ePatra::animate(int32_t index)
16212 {
16213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62362 times.
62362 if(switch_hooked) return enemy::animate(index);
16214
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 61552 times.
62362 if(dying)
16215 {
16216
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 810 times.
882 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
16217 {
16218 72 ((enemy*)guys.spr(i))->hp = -1000;
16219 72 }
16220
16221 810 return Dead(index);
16222 }
16223
16224 61552 double basesize = 84;
16225
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc10) basesize = 90;
16226 61552 double halfsize = basesize / 2;
16227 61552 double quartersize = halfsize / 2;
16228 61552 double twothirdsize = (basesize / 3)*2;
16229 61552 double onethirdsize = (basesize / 3);
16230
16231
16232
2/2
✓ Branch 0 taken 47886 times.
✓ Branch 1 taken 13666 times.
61552 if(clk==0)
16233 {
16234 13666 removearmos(x,y,ffcactivated);
16235 13666 }
16236
16237
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61552 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61552 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
16238 {
16239
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61552 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
16240
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (loopcnt < 0) ++clk2;
16241
2/2
✓ Branch 0 taken 60857 times.
✓ Branch 1 taken 695 times.
61552 if(++clk2>basesize)
16242 {
16243 695 clk2=0;
16244
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 695 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
695 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
16245 {
16246
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 334 times.
695 if(loopcnt > 0)
16247 361 --loopcnt;
16248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 else if (loopcnt == 0)
16249 {
16250
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 128 times.
334 if((misc%dmisc6)==0)
16251 {
16252
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (dmisc21 > 0) loopcnt=-dmisc21;
16253 128 else loopcnt=dmisc7;
16254 128 }
16255 334 }
16256 else if (loopcnt == -1) loopcnt=dmisc7;
16257 else ++loopcnt;
16258
16259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
695 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
16260 695 }
16261 else
16262 {
16263 loopcnt = 0;
16264 misc = 1;
16265 }
16266 695 }
16267 61552 }
16268
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk4 > 0) --clk4;
16269
16270
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 < 0)
16271 {
16272 if (dmisc5 == 1 || dmisc5 == 3)
16273 {
16274 if (get_qr(qr_NEWENEMYTILES))
16275 {
16276 if (clk7 <= 0 || clk6 != -16) ++clk6;
16277 if (clk6 == 0) o_tile=d->e_tile;
16278 else
16279 {
16280 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
16281 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
16282 }
16283 }
16284 else clk6 = 0;
16285 }
16286 }
16287
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk6;
16288
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk5 < 0) ++clk5;
16289
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk5;
16290
16291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61552 if (clk7 > 0 && clk6 >= -16) --clk7;
16292
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 > 0) clk7 = 0;
16293
16294
2/2
✓ Branch 0 taken 244144 times.
✓ Branch 1 taken 61552 times.
305696 for(int32_t i=index+1; i<index+flycnt+1; i++)
16295 {
16296 //outside ring
16297
2/2
✓ Branch 0 taken 243720 times.
✓ Branch 1 taken 424 times.
244144 if(!adjusted)
16298 {
16299
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 152 times.
424 if(get_qr(qr_NEWENEMYTILES))
16300 {
16301 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
16302 272 enemy *s = ((enemy*)guys.spr(i));
16303 272 s->parent_script_UID = this->script_UID;
16304 272 }
16305 else
16306 {
16307 152 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16308 152 enemy *s = ((enemy*)guys.spr(i));
16309 152 s->parent_script_UID = this->script_UID;
16310 }
16311
16312 424 ((enemy*)guys.spr(i))->cs=dmisc9;
16313 424 ((enemy*)guys.spr(i))->hp=dmisc3;
16314 424 }
16315
16316
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 243783 times.
244144 if(((enemy*)guys.spr(i))->hp <= 0)
16317 {
16318
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 361 times.
1655 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16319 {
16320 1294 guys.swap(j,j+1);
16321 1294 }
16322
16323
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
361 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
16324 361 }
16325 else
16326 {
16327 243783 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16328
1/2
✓ Branch 0 taken 243783 times.
✗ Branch 1 not taken.
243783 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
16329
16330
2/2
✓ Branch 0 taken 86967 times.
✓ Branch 1 taken 156816 times.
243783 if(!dmisc4) //Big Ring
16331 {
16332 //maybe playing_field_offset here?
16333
2/2
✓ Branch 0 taken 84872 times.
✓ Branch 1 taken 71944 times.
156816 if(loopcnt>0)
16334 {
16335
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16336
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16337 84872 }
16338 else
16339 {
16340 71944 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16341 71944 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16342 }
16343
16344 156816 temp_x=guys.spr(i)->x;
16345 156816 temp_y=guys.spr(i)->y;
16346 156816 }
16347 else //Oval
16348 {
16349 86967 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16350 86967 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16351
16352
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36825 times.
86967 if(loopcnt>0)
16353 {
16354 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16355
1/2
✓ Branch 0 taken 50142 times.
✗ Branch 1 not taken.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
16356 50142 }
16357 else
16358 {
16359 36825 guys.spr(i)->x = circle_x;
16360 36825 guys.spr(i)->y = circle_y;
16361 }
16362
16363 86967 temp_x=circle_x;
16364 86967 temp_y=circle_y;
16365 }
16366
16367 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16368 243783 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16369
16370
4/4
✓ Branch 0 taken 46216 times.
✓ Branch 1 taken 197567 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30939 times.
243783 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16371 {
16372 30939 guys.spr(i)->dir=l_down;
16373 30939 }
16374
4/4
✓ Branch 0 taken 46264 times.
✓ Branch 1 taken 166580 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30987 times.
212844 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16375 {
16376 30987 guys.spr(i)->dir=left;
16377 30987 }
16378
4/4
✓ Branch 0 taken 45998 times.
✓ Branch 1 taken 135859 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30721 times.
181857 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16379 {
16380 30721 guys.spr(i)->dir=l_up;
16381 30721 }
16382
4/4
✓ Branch 0 taken 45644 times.
✓ Branch 1 taken 105492 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30367 times.
151136 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16383 {
16384 30367 guys.spr(i)->dir=up;
16385 30367 }
16386
4/4
✓ Branch 0 taken 45419 times.
✓ Branch 1 taken 75350 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30142 times.
120769 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16387 {
16388 30142 guys.spr(i)->dir=r_up;
16389 30142 }
16390
4/4
✓ Branch 0 taken 45271 times.
✓ Branch 1 taken 45356 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 29994 times.
90627 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16391 {
16392 29994 guys.spr(i)->dir=right;
16393 29994 }
16394
4/4
✓ Branch 0 taken 45354 times.
✓ Branch 1 taken 15279 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30077 times.
60633 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16395 {
16396 30077 guys.spr(i)->dir=r_down;
16397 30077 }
16398 else
16399 {
16400 30556 guys.spr(i)->dir=down;
16401 }
16402
16403 243783 guys.spr(i)->x += x;
16404 243783 guys.spr(i)->y += y;
16405 }
16406 244144 }
16407
16408
7/22
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39936 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
61552 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
16409 {
16410 15803 int timeneeded = 48;
16411 15803 int patbreath = (zc_oldrand()%50+50);
16412
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
16413
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
16414 {
16415 timeneeded = 48 + patbreath;
16416 }
16417
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
16418 {
16419 timeneeded = 48 + 96;
16420 }
16421
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16422
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16423
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16424 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16425 133 && (clk6 >= 0) //if not in the middle of firing...
16426 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
16427
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16428 {
16429
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
16430 {
16431 case patratSTREAM:
16432 {
16433 clk7 = 97;
16434 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16435 else clk6 = 0;
16436 break;
16437 }
16438 case patratBREATH:
16439 {
16440 clk7 = patbreath;
16441 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16442 else clk6 = 0;
16443 break;
16444 }
16445 default:
16446 {
16447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16448 {
16449 clk6 = -48;
16450 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16451 }
16452 else
16453 {
16454 133 clk6 = 0;
16455
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16456 133 FirePatraWeapon();
16457 }
16458 133 break;
16459 }
16460 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16461 133 }
16462
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
16463 {
16464 switch(dmisc28)
16465 {
16466 case patratSTREAM:
16467 {
16468 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16469 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16470 break;
16471 }
16472 case patratBREATH:
16473 {
16474 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16475 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16476 break;
16477 }
16478 default:
16479 {
16480 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16481 {
16482 FirePatraWeapon();
16483 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16484 }
16485 break;
16486 }
16487 }
16488 }
16489 15803 }
16490
16491 61552 int randattempts = 0;
16492 61552 int randeye = 0;
16493
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if (flycnt2 > 0)
16494 {
16495 16602 do
16496 {
16497
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16498 16602 randeye += (index + flycnt + 1);
16499 16602 ++randattempts;
16500
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16501 16602 }
16502 61552 bool dofire = false;
16503
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc20)
16504 {
16505 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16506 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16507 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16508 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16509 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16510 {
16511 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16512 {
16513 if (clk5 >= dmisc19)
16514 {
16515 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16516 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16517 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16518 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16519 || dmisc18 == -1)
16520 dofire = true;
16521 }
16522 }
16523 }
16524 }
16525
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if(flycnt2)
16526 {
16527
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16528 {
16529
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
16530 {
16531 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16532
16533
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_qr(qr_NEWENEMYTILES))
16534 {
16535
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16536 {
16537
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
16538 {
16539 // Center eye shoots projectiles; make room for its firing tiles
16540 case 1:
16541 case 3:
16542 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16543 48 break;
16544
16545 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16546 default:
16547 case 2:
16548 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16549 40 break;
16550 }
16551 88 }
16552 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16553 88 }
16554 else
16555 {
16556 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16557 }
16558
16559 88 ((enemy*)guys.spr(i))->cs=dmisc9;
16560
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16561 88 }
16562
16563
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
16564 {
16565 94136 ((enemy*)guys.spr(i))->superman=true;
16566 94136 }
16567 else
16568 {
16569 25839 ((enemy*)guys.spr(i))->superman=false;
16570 }
16571
16572
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
16573 {
16574
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16575 {
16576 144 guys.swap(j,j+1);
16577 144 }
16578
16579
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16580 72 }
16581 else
16582 {
16583 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16584
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16585
16586
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
16587 {
16588
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
16589 {
16590
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16591
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16592 58268 }
16593 else
16594 {
16595 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16596 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16597 }
16598
16599 112644 temp_x=guys.spr(i)->x;
16600 112644 temp_y=guys.spr(i)->y;
16601 112644 }
16602 else
16603 {
16604 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16605 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16606
16607
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16608 {
16609 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16610
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16611 3965 }
16612 else
16613 {
16614 3294 guys.spr(i)->x = circle_x;
16615 3294 guys.spr(i)->y = circle_y;
16616 }
16617
16618 7259 temp_x=circle_x;
16619 7259 temp_y=circle_y;
16620 }
16621
16622 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16623 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16624
16625
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16626 {
16627 14941 guys.spr(i)->dir=l_down;
16628 14941 }
16629
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16630 {
16631 14928 guys.spr(i)->dir=left;
16632 14928 }
16633
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16634 {
16635 14937 guys.spr(i)->dir=l_up;
16636 14937 }
16637
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16638 {
16639 14996 guys.spr(i)->dir=up;
16640 14996 }
16641
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16642 {
16643 15041 guys.spr(i)->dir=r_up;
16644 15041 }
16645
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16646 {
16647 15035 guys.spr(i)->dir=right;
16648 15035 }
16649
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16650 {
16651 15035 guys.spr(i)->dir=r_down;
16652 15035 }
16653 else
16654 {
16655 14990 guys.spr(i)->dir=down;
16656 }
16657
16658 119903 guys.spr(i)->x += x;
16659 119903 guys.spr(i)->y = y-guys.spr(i)->y;
16660
16661
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16662 {
16663 /*
16664 if(!(zc_oldrand()&127))
16665 {
16666 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16667 sfx(wpnsfx(wpn),pan(int32_t(x)));
16668 }
16669 */
16670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16671 {
16672 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16673 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16674 {
16675 if (dmisc5 == 3)
16676 {
16677 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16678 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16679 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16680 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16681 }
16682 else
16683 {
16684 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16685 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16686 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16687 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16688 }
16689 }
16690 else
16691 {
16692 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16693 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16694 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16695 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16696 }
16697 }
16698
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16699
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16700
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16701 {
16702
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
16703 {
16704 case 4: //Single one rapidfires
16705 {
16706 if (dofire && i == randeye)
16707 {
16708 ((esPatra*)guys.spr(i))->clk5 = -16;
16709 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16710 ((esPatra*)guys.spr(i))->clk4 = 96;
16711 clk5 = -3;
16712 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16713 }
16714 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16715 {
16716 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16717 sfx(wpnsfx(wpn),pan(int32_t(x)));
16718 }
16719 break;
16720 }
16721 case 3: //Ring
16722 {
16723 if (dofire)
16724 {
16725 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16726 {
16727 ((esPatra*)guys.spr(i))->clk5 = -48;
16728 clk5 = -48;
16729 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16730 }
16731 else
16732 {
16733 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16734 sfx(wpnsfx(wpn),pan(int32_t(x)));
16735 int32_t m=Ewpns.Count()-1;
16736 weapon *ew = (weapon*)(Ewpns.spr(m));
16737
16738 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16739 ((esPatra*)guys.spr(i))->clk5 = 0;
16740 clk5 = 0;
16741 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16742 }
16743 }
16744 if (((esPatra*)guys.spr(i))->clk5 == -16)
16745 {
16746 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16747 sfx(wpnsfx(wpn),pan(int32_t(x)));
16748 int32_t m=Ewpns.Count()-1;
16749 weapon *ew = (weapon*)(Ewpns.spr(m));
16750
16751 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16752 }
16753 break;
16754 }
16755 case 2: //one after another
16756 {
16757 if (dofire)
16758 {
16759 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16760 clk5 = -48 - (12*flycnt2);
16761 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16762 }
16763 if (((esPatra*)guys.spr(i))->clk5 == -16)
16764 {
16765 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16766 sfx(wpnsfx(wpn),pan(int32_t(x)));
16767 }
16768 break;
16769 }
16770 case 1: //random one eye
16771 {
16772 if (dofire && i == randeye)
16773 {
16774 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16775 {
16776 ((esPatra*)guys.spr(i))->clk5 = -48;
16777 clk5 = -48;
16778 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16779 }
16780 else
16781 {
16782 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16783 sfx(wpnsfx(wpn),pan(int32_t(x)));
16784 ((esPatra*)guys.spr(i))->clk5 = 0;
16785 clk5 = 0;
16786 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16787 }
16788 }
16789 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16790 {
16791 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16792 sfx(wpnsfx(wpn),pan(int32_t(x)));
16793 }
16794 break;
16795 }
16796 default: //old behavior, all eyes can fire any time
16797 {
16798
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16799
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16800
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16801 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16802 {
16803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16804 {
16805 ((esPatra*)guys.spr(i))->clk5 = -48;
16806 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16807 }
16808 else
16809 {
16810 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16811 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
16812 292 ((esPatra*)guys.spr(i))->clk5 = 0;
16813
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16814 }
16815 292 }
16816
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16817 {
16818 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16819 sfx(wpnsfx(wpn),pan(int32_t(x)));
16820 }
16821 38077 break;
16822 }
16823 }
16824 38077 }
16825 38077 }
16826
16827 }
16828 119975 }
16829 16602 }
16830
16831 61552 adjusted=true;
16832 61552 return enemy::animate(index);
16833 62362 }
16834
16835 133 void ePatra::FirePatraWeapon()
16836 { //.707
16837 133 int32_t xoff = 0;
16838 133 int32_t yoff = 0;
16839
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16840 {
16841 xoff += (hit_width/2)-8;
16842 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16843 }
16844
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16845 {
16846 yoff += (hit_height/2)-8;
16847 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16848 }
16849 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16850
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
16851 {
16852 case patrat8SHOT: //Fire Wizzrobe
16853 case patrat4SHOTDIAG:
16854 case patrat4SHOTRAND:
16855 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16856 {
16857 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16858 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16859 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16860 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16861
16862 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16863 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16864 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16865 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16866
16867 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16868 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16869 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16870 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16871
16872 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16873 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16875 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16876
16877 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16878 }
16879
16880 [[fallthrough]];
16881 case patrat4SHOTCARD: //Stalfos 3
16882 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16883 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16884 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16885 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16886 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16887 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16888 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16889 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16890 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16891 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16892 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16893 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16894 break;
16895
16896 default:
16897 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16898
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16899 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16900
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16901
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16902 {
16903 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16904 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16905 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16906 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16907 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16908 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16909 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16910 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16911 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16912 {
16913 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16914 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16916 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16917 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16919 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16920 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16921 }
16922 }
16923 133 break;
16924
16925 }
16926 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16927 //+0.46364761
16928 //11.80
16929 133 }
16930
16931 124918 void ePatra::draw(BITMAP *dest)
16932 {
16933 124918 tile=o_tile;
16934 124918 update_enemy_frame();
16935 124918 enemy::draw(dest);
16936 124918 }
16937
16938 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16939 {
16940 int32_t ret = enemy::defend(wpnId, power, edef);
16941
16942 if(ret < 0 && (flycnt||flycnt2))
16943 return 0;
16944
16945 return ret;
16946 }
16947
16948 908 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16949 {
16950 908 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16951
16952
6/6
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 145 times.
908 if(ret < 0 && (flycnt||flycnt2))
16953 660 return 0;
16954
16955 248 return ret;
16956 908 }
16957
16958 1536 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16959 1024 {
16960 //cs=8;
16961 512 item_set=0;
16962 512 misc=clk;
16963 512 clk4 = 0;
16964 512 clk5 = 0;
16965 512 clk = -((misc*21)>>1)-1;
16966
3/6
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 512 times.
✗ Branch 5 not taken.
512 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16967 512 hit_width=12;
16968 512 hit_height=12;
16969 512 hxofs=2;
16970 512 hyofs=2;
16971 512 extend = 0;
16972 512 txsz = 1;
16973 512 tysz = 1;
16974 /* //These need to be separate enemy editor fields. This enemy class also it's draw altered to correctly support big stuff.
16975 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16976 int32_t prntSIZEflags = prntenemy->SIZEflags;
16977 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16978 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16979 // al_trace("Enemy txsz:%i\n", txsz);
16980 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16981 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16982 else
16983 hxsz=12;
16984 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16985 else
16986 hysz=12;
16987 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16988 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16989 else
16990 hxofs=2;
16991 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16992 else hyofs=2;
16993 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16994 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16995 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16996 {
16997 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16998 }
16999
17000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
17001 */
17002 512 mainguy=count_enemy=false;
17003 512 bgsfx=-1;
17004 //o_tile=0;
17005 512 flags &= (~guy_neverret);
17006 512 deadsfx = WAV_EDEAD;
17007 512 hitsfx = WAV_EHIT;
17008 512 isCore = false;
17009 512 }
17010
17011 372279 bool esPatra::animate(int32_t index)
17012 {
17013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372279 times.
372279 if(switch_hooked) return enemy::animate(index);
17014
2/2
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 364413 times.
372279 if(dying)
17015 7866 return Dead(index);
17016
17017 364413 return enemy::animate(index);
17018 372279 }
17019
17020 747310 void esPatra::draw(BITMAP *dest)
17021 {
17022
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 202590 times.
747310 if(get_qr(qr_NEWENEMYTILES))
17023 {
17024 544720 tile = o_tile+(clk&3);
17025
17026
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
17027 {
17028 case up: //u
17029 67770 flip=0;
17030 67770 break;
17031
17032 case down: //d
17033 69066 flip=0;
17034 69066 tile+=4;
17035 69066 break;
17036
17037 case left: //l
17038 67800 flip=0;
17039 67800 tile+=8;
17040 67800 break;
17041
17042 case right: //r
17043 67996 flip=0;
17044 67996 tile+=12;
17045 67996 break;
17046
17047 case l_up: //ul
17048 67484 flip=0;
17049 67484 tile+=20;
17050 67484 break;
17051
17052 case r_up: //ur
17053 68044 flip=0;
17054 68044 tile+=24;
17055 68044 break;
17056
17057 case l_down: //dl
17058 68474 flip=0;
17059 68474 tile+=28;
17060 68474 break;
17061
17062 case r_down: //dr
17063 68086 flip=0;
17064 68086 tile+=32;
17065 68086 break;
17066 }
17067 544720 }
17068 else
17069 {
17070 202590 tile = o_tile+((clk&2)>>1);
17071 }
17072
17073
2/2
✓ Branch 0 taken 38248 times.
✓ Branch 1 taken 709062 times.
747310 if(clk>=0)
17074 709062 enemy::draw(dest);
17075 747310 }
17076
17077
17078 6 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
17079 6 {
17080 3 adjusted=false;
17081
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
17082
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
17083 3 clk4 = 0;
17084 3 clk5 = 0;
17085 //flycnt=6; flycnt2=0;
17086 3 flycnt=dmisc1;
17087 3 flycnt2=0; // PatraBS doesn't have inner rings!
17088 3 loopcnt=0;
17089
17090 3 SIZEflags = d->SIZEflags;
17091
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17092 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17093 // al_trace("Enemy txsz:%i\n", txsz);
17094
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
17096 3 else hit_width = 32;
17097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
17098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17100 3 else hxofs=-8;
17101
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17102 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
17104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17105 {
17106 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17107 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
17108 }
17109
17110
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
17111
17112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
17113
17114 //nets+4480;
17115 3 }
17116
17117 1862 bool ePatraBS::animate(int32_t index)
17118 {
17119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
17120
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
17121 54 return Dead(index);
17122
17123
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
17124 {
17125 442 removearmos(x,y,ffcactivated);
17126 442 }
17127
17128 1808 variable_walk_8(rate,homing,hrate,spw_floater);
17129
17130
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
17131 {
17132 19 clk2=0;
17133
17134
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
17135 12 --loopcnt;
17136 else
17137 {
17138
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
17139 4 loopcnt=dmisc7;
17140 }
17141
17142 19 ++misc;
17143 19 }
17144
17145 // double size=1;;
17146
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
17147 {
17148
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
17149 {
17150 18 ((enemy*)guys.spr(i))->hp=dmisc3;
17151
17152
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_qr(qr_NEWENEMYTILES))
17153 {
17154 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
17155 18 }
17156 else
17157 {
17158 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
17159 }
17160
17161 18 ((enemy*)guys.spr(i))->cs = dmisc9;
17162 18 }
17163
17164
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
17165 {
17166
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
17167 {
17168 26 guys.swap(j,j+1);
17169 26 }
17170
17171 18 --flycnt;
17172 18 }
17173 else
17174 {
17175 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
17176
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
17177 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
17178 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
17179
17180
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
17181 {
17182 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
17183
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
17184 2305 }
17185 else
17186 {
17187 2132 guys.spr(i)->x = temp_x;
17188 2132 guys.spr(i)->y = temp_y;
17189 }
17190
17191 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17192 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
17193
17194
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17195 {
17196 551 guys.spr(i)->dir=l_down;
17197 551 }
17198
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17199 {
17200 534 guys.spr(i)->dir=left;
17201 534 }
17202
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17203 {
17204 522 guys.spr(i)->dir=l_up;
17205 522 }
17206
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17207 {
17208 564 guys.spr(i)->dir=up;
17209 564 }
17210
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17211 {
17212 545 guys.spr(i)->dir=r_up;
17213 545 }
17214
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17215 {
17216 562 guys.spr(i)->dir=right;
17217 562 }
17218
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17219 {
17220 554 guys.spr(i)->dir=r_down;
17221 554 }
17222 else
17223 {
17224 605 guys.spr(i)->dir=down;
17225 }
17226
17227 4437 guys.spr(i)->x += x;
17228 4437 guys.spr(i)->y += y;
17229 }
17230 4455 }
17231
17232 1808 adjusted=true;
17233 1808 return enemy::animate(index);
17234 1862 }
17235
17236 3724 void ePatraBS::draw(BITMAP *dest)
17237 {
17238 3724 tile=o_tile;
17239
17240
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_qr(qr_NEWENEMYTILES))
17241 {
17242 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17243 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
17244
17245
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17246 {
17247 102 lookat=l_down;
17248 102 }
17249
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17250 {
17251 310 lookat=down;
17252 310 }
17253
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17254 {
17255 952 lookat=r_down;
17256 952 }
17257
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17258 {
17259 1686 lookat=right;
17260 1686 }
17261
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17262 {
17263 180 lookat=r_up;
17264 180 }
17265
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17266 {
17267 lookat=up;
17268 }
17269
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 302 times.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17270 {
17271 lookat=l_up;
17272 }
17273 else
17274 {
17275 494 lookat=left;
17276 }
17277
17278
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
17279 {
17280 case up: //u
17281 flip=0;
17282 break;
17283
17284 case down: //d
17285 310 flip=0;
17286 310 tile+=8;
17287 310 break;
17288
17289 case left: //l
17290 494 flip=0;
17291 494 tile+=40;
17292 494 break;
17293
17294 case right: //r
17295 1686 flip=0;
17296 1686 tile+=48;
17297 1686 break;
17298
17299 case l_up: //ul
17300 flip=0;
17301 tile+=80;
17302 break;
17303
17304 case r_up: //ur
17305 180 flip=0;
17306 180 tile+=88;
17307 180 break;
17308
17309 case l_down: //dl
17310 102 flip=0;
17311 102 tile+=120;
17312 102 break;
17313
17314 case r_down: //dr
17315 952 flip=0;
17316 952 tile+=128;
17317 952 break;
17318 }
17319
17320 3724 tile+=(2*(clk&3));
17321 3724 xofs-=8;
17322 3724 yofs-=8;
17323 3724 drawblock(dest,15);
17324 3724 xofs+=8;
17325 3724 yofs+=8;
17326 3724 }
17327 else
17328 {
17329 flip=(clk&1);
17330 xofs-=8;
17331 yofs-=8;
17332 enemy::draw(dest);
17333 xofs+=16;
17334 enemy::draw(dest);
17335 yofs+=16;
17336 enemy::draw(dest);
17337 xofs-=16;
17338 enemy::draw(dest);
17339 xofs+=8;
17340 yofs-=8;
17341 }
17342 3724 }
17343
17344 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
17345 {
17346 int32_t ret = enemy::defend(wpnId, power, edef);
17347
17348 if(ret < 0 && (flycnt||flycnt2))
17349 return 0;
17350
17351 return ret;
17352 }
17353
17354 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
17355 {
17356 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
17357
17358
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
17359 19 return 0;
17360
17361 6 return ret;
17362 25 }
17363
17364 54 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17365 36 {
17366 //cs=csBOSS;
17367 18 item_set=0;
17368 18 misc=clk;
17369 18 clk = -((misc*21)>>1)-1;
17370 18 clk4 = 0;
17371 18 clk5 = 0;
17372
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
17373 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
17374
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17375 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17376 // al_trace("Enemy txsz:%i\n", txsz);
17377
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
17378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
17379 18 else hit_width=16;
17380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17381 18 else hit_height=16;
17382
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17383
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17385 18 else hyofs=2;
17386 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17387
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17389 {
17390 yofs = (int32_t)prntenemy->yofs;
17391 }
17392
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17393
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17394
17395 18 bgsfx=-1;
17396 18 mainguy=count_enemy=false;
17397 18 deadsfx = WAV_EDEAD;
17398 18 hitsfx = WAV_EHIT;
17399 18 flags &= ~guy_neverret;
17400 18 isCore = false;
17401 18 }
17402
17403 4790 bool esPatraBS::animate(int32_t index)
17404 {
17405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
17406
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
17407 324 return Dead(index);
17408
17409 4466 return enemy::animate(index);
17410 4790 }
17411
17412 9580 void esPatraBS::draw(BITMAP *dest)
17413 {
17414 9580 tile=o_tile;
17415
17416
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_qr(qr_NEWENEMYTILES))
17417 {
17418
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
17419 {
17420 case up: //u
17421 1280 flip=0;
17422 1280 break;
17423
17424 case down: //d
17425 1326 flip=0;
17426 1326 tile+=4;
17427 1326 break;
17428
17429 case left: //l
17430 1076 flip=0;
17431 1076 tile+=8;
17432 1076 break;
17433
17434 case right: //r
17435 1254 flip=0;
17436 1254 tile+=12;
17437 1254 break;
17438
17439 case l_up: //ul
17440 1080 flip=0;
17441 1080 tile+=20;
17442 1080 break;
17443
17444 case r_up: //ur
17445 1238 flip=0;
17446 1238 tile+=24;
17447 1238 break;
17448
17449 case l_down: //dl
17450 1146 flip=0;
17451 1146 tile+=28;
17452 1146 break;
17453
17454 case r_down: //dr
17455 1180 flip=0;
17456 1180 tile+=32;
17457 1180 break;
17458 }
17459
17460 9580 tile += ((clk&6)>>1);
17461 9580 }
17462 else
17463 {
17464 tile += (clk&4)?1:0;
17465 }
17466
17467
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
17468 8608 enemy::draw(dest);
17469 9580 }
17470
17471
17472 /**********************************/
17473 /********** Misc Code ***********/
17474 /**********************************/
17475
17476 162470 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17477 {
17478
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 40366 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
162470 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17479
4/8
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162470 times.
✗ Branch 7 not taken.
162470 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17480
1/2
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
162470 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17481 162470 }
17482
17483 36428 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17484 {
17485 // Kludge
17486
4/8
✓ Branch 0 taken 36428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36428 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36428 times.
✗ Branch 7 not taken.
36428 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17487 36428 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36428 times.
36428 delete w;
17489 36428 return ret;
17490 }
17491
17492 4230 void enemy_scored(int32_t index)
17493 {
17494 4230 ((enemy*)guys.spr(index))->scored=true;
17495 4230 }
17496
17497 1440 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17498 {
17499
7/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 1325 times.
✓ Branch 10 taken 1440 times.
✗ Branch 11 not taken.
1440 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17500
3/6
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1440 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17501 {
17502 g->o_tile = parentscr->guytile;
17503 if(g->o_tile != 0)
17504 g->flags &= ~guy_invisible;
17505 g->cs = parentscr->guycs;
17506 }
17507 1440 guys.add(g);
17508 1440 }
17509
17510 22137 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17511 {
17512
5/10
✓ Branch 0 taken 22137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22137 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 22137 times.
✗ Branch 9 not taken.
22137 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), zfix(0), id, pickup, 0);
17513 22137 items.add(i);
17514 22137 }
17515
17516 80 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17517 {
17518
6/12
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 80 times.
✗ Branch 11 not taken.
80 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17519 80 items.add(i);
17520 80 }
17521
17522 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17523 {
17524 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17525 items.add(i);
17526 }
17527
17528 79 void kill_em_all()
17529 {
17530
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 79 times.
375 for(int32_t i=0; i<guys.Count(); i++)
17531 {
17532 296 enemy *e = ((enemy*)guys.spr(i));
17533
17534
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17535
17536 271 e->kickbucket();
17537 271 }
17538 79 }
17539
17540 bool can_kill_em_all()
17541 {
17542 for(int32_t i=0; i<guys.Count(); i++)
17543 {
17544 enemy *e = ((enemy*)guys.spr(i));
17545
17546 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17547 if(e->superman) continue;
17548 return true;
17549 }
17550 return false;
17551 }
17552
17553 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17554 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17555 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17556 {
17557 for(int32_t i=0; i<guys.Count(); i++)
17558 {
17559 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17560 {
17561 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17562 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17563 {
17564 return i;
17565 }
17566 }
17567 }
17568
17569 return -1;
17570 }
17571
17572 6672884 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17573 {
17574
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6672884 times.
✓ Branch 2 taken 19148078 times.
✓ Branch 3 taken 6655598 times.
25803676 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17575 {
17576
2/2
✓ Branch 0 taken 17286 times.
✓ Branch 1 taken 19130792 times.
19148078 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17577 {
17578 17286 return i;
17579 }
17580 19130792 }
17581
17582 6655598 return -1;
17583 6672884 }
17584
17585 // For Hero's hit detection. Count them if they are dying.
17586 27398 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17587 {
17588 27398 enemy *e = (enemy*)guys.spr(index);
17589
3/4
✓ Branch 0 taken 27398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14844 times.
✓ Branch 3 taken 12554 times.
27398 if(!e || e->hp > 0)
17590 14844 return -1;
17591
17592 12554 bool d = e->dying;
17593 12554 int32_t hc = e->hclk;
17594 12554 e->dying = false;
17595 12554 e->hclk = 0;
17596 12554 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17597 12554 e->dying = d;
17598 12554 e->hclk = hc;
17599
17600
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 12433 times.
12554 return hit ? index : -1;
17601 27398 }
17602
17603 7286185 bool hasMainGuy()
17604 {
17605
2/2
✓ Branch 0 taken 8740127 times.
✓ Branch 1 taken 2591007 times.
11331134 for(int32_t i=0; i<guys.Count(); i++)
17606 {
17607
2/2
✓ Branch 0 taken 4695178 times.
✓ Branch 1 taken 4044949 times.
8740127 if(((enemy*)guys.spr(i))->mainguy)
17608 {
17609 4695178 return true;
17610 }
17611 4044949 }
17612
17613 2591007 return false;
17614 7286185 }
17615
17616 51 void EatHero(int32_t index)
17617 {
17618 51 ((eStalfos*)guys.spr(index))->eathero();
17619 51 }
17620
17621 3 void GrabHero(int32_t index)
17622 {
17623 3 ((eWallM*)guys.spr(index))->grabhero();
17624 3 }
17625
17626 292 bool CarryHero()
17627 {
17628
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
17629 {
17630
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17631 {
17632
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
17633 {
17634 292 Hero.x=guys.spr(i)->x;
17635 292 Hero.y=guys.spr(i)->y;
17636 292 return ((eWallM*)guys.spr(i))->misc > 0;
17637 }
17638 63 }
17639
17640 // Like Likes currently can't carry Hero.
17641 /*
17642 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17643 {
17644 if(((eLikeLike*)guys.spr(i))->hashero)
17645 {
17646 Hero.x=guys.spr(i)->x;
17647 Hero.y=guys.spr(i)->y;
17648 return (true);
17649 }
17650 }*/
17651 599 }
17652
17653 return false;
17654 292 }
17655
17656 // Move item with guy
17657 void movefairy(zfix &x,zfix &y,int32_t misc)
17658 {
17659 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17660
17661 if(i!=-1)
17662 {
17663 x = guys.spr(i)->x;
17664 y = guys.spr(i)->y;
17665 }
17666 }
17667
17668 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17669 void movefairy2(zfix x,zfix y,int32_t misc)
17670 {
17671 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17672
17673 if(i!=-1)
17674 {
17675 guys.spr(i)->x = x;
17676 guys.spr(i)->y = y;
17677 }
17678 }// Move item with guy
17679
17680 33988 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17681 {
17682 33988 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17683
17684
1/2
✓ Branch 0 taken 33988 times.
✗ Branch 1 not taken.
33988 if(fairy)
17685 {
17686 33988 x = fairy->x;
17687 33988 y = fairy->y;
17688 33988 }
17689 33988 }
17690
17691 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17692 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17693 {
17694 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17695
17696 if(fairy)
17697 {
17698 fairy->x = x;
17699 fairy->y = y;
17700 }
17701 }
17702
17703 void killfairy(int32_t misc)
17704 {
17705 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17706 guys.del(i);
17707 }
17708
17709 int32_t getGuyIndex(const int32_t eid)
17710 {
17711 for(word i = 0; i < guys.Count(); i++)
17712 {
17713 if(guys.spr(i)->getUID() == eid)
17714 return i;
17715 }
17716
17717 return -1;
17718 }
17719
17720 void killfairynew(item const &itemfairy)
17721 {
17722 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17723 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17724 }
17725
17726 //Should probably change this to return an 'enemy*', null on failure -Em
17727 13284 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17728 {
17729 13284 return addenemy(x,y,0,id,clk);
17730 }
17731
17732 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17733 {
17734 868 return addchild(x,y,0,id,clk, parent_scriptUID);
17735 }
17736
17737 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17738 {
17739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
17740
17741 893 int32_t ret = 0;
17742 893 sprite *e=NULL;
17743 893 al_trace("Adding child\n");
17744
17745
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
17746 {
17747 //Fixme: possible enemy memory leak. (minor)
17748 case eeWALK:
17749
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17750 16 break;
17751
17752 case eeLEV:
17753 e = new eLeever((zfix)x,(zfix)y,id,clk);
17754 break;
17755
17756 case eeTEK:
17757 e = new eTektite((zfix)x,(zfix)y,id,clk);
17758 break;
17759
17760 case eePEAHAT:
17761 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17762 break;
17763
17764 case eeZORA:
17765 e = new eZora((zfix)x,(zfix)y,id,clk);
17766 break;
17767
17768 case eeGHINI:
17769 e = new eGhini((zfix)x,(zfix)y,id,clk);
17770 break;
17771
17772 case eeKEESE:
17773
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
17774 857 break;
17775
17776 case eeWIZZ:
17777
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17778 15 break;
17779
17780 case eePROJECTILE:
17781 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17782 break;
17783
17784 case eeWALLM:
17785 e = new eWallM((zfix)x,(zfix)y,id,clk);
17786 break;
17787
17788 case eeAQUA:
17789 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17790 break;
17791
17792 case eeMOLD:
17793 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17794 break;
17795
17796 case eeMANHAN:
17797
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17798 1 break;
17799
17800 case eeGLEEOK:
17801 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17802 break;
17803
17804 case eeGHOMA:
17805 e = new eGohma((zfix)x,(zfix)y,id,clk);
17806 break;
17807
17808 case eeLANM:
17809 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
17810 break;
17811
17812 case eeGANON:
17813 e = new eGanon((zfix)x,(zfix)y,id,clk);
17814 break;
17815
17816 case eeFAIRY:
17817 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17818 break;
17819
17820 case eeFIRE:
17821 e = new eFire((zfix)x,(zfix)y,id,clk);
17822 break;
17823
17824 case eeOTHER:
17825 e = new eOther((zfix)x,(zfix)y,id,clk);
17826 break;
17827
17828
17829 case eeSCRIPT01:
17830 case eeSCRIPT02:
17831 case eeSCRIPT03:
17832 case eeSCRIPT04:
17833 case eeSCRIPT05:
17834 case eeSCRIPT06:
17835 case eeSCRIPT07:
17836 case eeSCRIPT08:
17837 case eeSCRIPT09:
17838 case eeSCRIPT10:
17839 case eeSCRIPT11:
17840 case eeSCRIPT12:
17841 case eeSCRIPT13:
17842 case eeSCRIPT14:
17843 case eeSCRIPT15:
17844 case eeSCRIPT16:
17845 case eeSCRIPT17:
17846 case eeSCRIPT18:
17847 case eeSCRIPT19:
17848 case eeSCRIPT20:
17849 {
17850 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17851 {
17852 e = new eScript((zfix)x,(zfix)y,id,clk);
17853 break;
17854 }
17855 else return 0;
17856 }
17857
17858 case eeFFRIENDLY01:
17859 case eeFFRIENDLY02:
17860 case eeFFRIENDLY03:
17861 case eeFFRIENDLY04:
17862 case eeFFRIENDLY05:
17863 case eeFFRIENDLY06:
17864 case eeFFRIENDLY07:
17865 case eeFFRIENDLY08:
17866 case eeFFRIENDLY09:
17867 case eeFFRIENDLY10:
17868 {
17869 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17870 {
17871 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17872 }
17873 else return 0;
17874
17875 }
17876
17877 case eeSPINTILE:
17878 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17879 break;
17880
17881 // and these enemies use the misc10/misc2 value
17882 case eeROCK:
17883 {
17884 switch(guysbuf[id&0xFFF].misc10)
17885 {
17886 case 1:
17887 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17888 break;
17889
17890 case 0:
17891 default:
17892 e = new eRock((zfix)x,(zfix)y,id,clk);
17893 break;
17894 }
17895
17896 break;
17897 }
17898
17899 case eeTRAP:
17900 {
17901 switch(guysbuf[id&0xFFF].misc2)
17902 {
17903 case 1:
17904 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17905 break;
17906
17907 case 0:
17908 default:
17909 e = new eTrap((zfix)x,(zfix)y,id,clk);
17910 break;
17911 }
17912
17913 break;
17914 }
17915
17916 case eeDONGO:
17917 {
17918 switch(guysbuf[id&0xFFF].misc10)
17919 {
17920 case 1:
17921 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17922 break;
17923
17924 case 0:
17925 default:
17926 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17927 break;
17928 }
17929
17930 break;
17931 }
17932
17933 case eeDIG:
17934 {
17935
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
17936 {
17937 case 1:
17938 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17939 break;
17940
17941 4 case 0:
17942 default:
17943
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17944 4 break;
17945 }
17946
17947 4 break;
17948 }
17949
17950 case eePATRA:
17951 {
17952 switch(guysbuf[id&0xFFF].misc10)
17953 {
17954 case 1:
17955 if (get_qr(qr_HARDCODED_BS_PATRA))
17956 {
17957 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17958 break;
17959 }
17960 [[fallthrough]];
17961 case 0:
17962 default:
17963 e = new ePatra((zfix)x,(zfix)y,id,clk);
17964 break;
17965 }
17966
17967 break;
17968 }
17969
17970 case eeGUY:
17971 {
17972 switch(guysbuf[id&0xFFF].misc10)
17973 {
17974 case 1:
17975 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17976 break;
17977
17978 case 0:
17979 default:
17980 e = new eNPC((zfix)x,(zfix)y,id,clk);
17981 break;
17982 }
17983
17984 break;
17985 }
17986
17987 case eeNONE:
17988 if(guysbuf[id&0xFFF].misc10 ==1)
17989 {
17990 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17991 break;
17992 break;
17993 }
17994 [[fallthrough]];
17995 default:
17996
17997 return 0;
17998 }
17999
18000 893 ret++; // Made one enemy.
18001
18002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
18003 {
18004 e->z = (zfix)z;
18005 }
18006
18007
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 ((enemy*)e)->ceiling = (z && canfall(id));
18008 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
18009 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
18010 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
18011 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18012 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18013
18014
18015
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
18016 {
18017 return 0;
18018 }
18019
18020 // add segments of segmented enemies
18021 893 int32_t c=0;
18022
18023
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
18024 {
18025 case eeMOLD:
18026 {
18027 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18028 id &= 0xFFF;
18029
18030 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18031 {
18032 //christ this is messy -DD
18033 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18034
18035 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18036 {
18037 al_trace("Moldorm segment %d could not be created!\n",i+1);
18038
18039 for(int32_t j=0; j<i+1; j++)
18040 guys.del(guys.Count()-1);
18041
18042 return 0;
18043 }
18044
18045 if(i>0)
18046 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18047
18048 ret++;
18049 }
18050
18051 break;
18052 }
18053
18054 case eeLANM:
18055 {
18056 id &= 0xFFF;
18057 int32_t shft = guysbuf[id].misc2;
18058 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18059
18060 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18061 {
18062 al_trace("Lanmola segment 1 could not be created!\n");
18063 guys.del(guys.Count()-1);
18064 return 0;
18065 }
18066
18067 ret++;
18068
18069 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18070 {
18071 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18072 {
18073 al_trace("Lanmola segment %d could not be created!\n",i+1);
18074
18075 for(int32_t j=0; j<i+1; j++)
18076 guys.del(guys.Count()-1);
18077
18078 return 0;
18079 }
18080
18081 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18082 ret++;
18083 }
18084 }
18085 break;
18086
18087 case eeMANHAN:
18088 1 id &= 0xFFF;
18089
18090
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18091 {
18092
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18093 {
18094 al_trace("Manhandla head %d could not be created!\n",i+1);
18095
18096 for(int32_t j=0; j<i+1; j++)
18097 {
18098 guys.del(guys.Count()-1);
18099 }
18100
18101 return 0;
18102 }
18103
18104 4 ret++;
18105 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18106 4 }
18107
18108 1 break;
18109
18110 case eeGLEEOK:
18111 {
18112 id &= 0xFFF;
18113
18114 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18115 {
18116 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
18117 {
18118 al_trace("Gleeok head %d could not be created!\n",i+1);
18119
18120 for(int32_t j=0; j<i+1; j++)
18121 {
18122 guys.del(guys.Count()-1);
18123 }
18124
18125 return false;
18126 }
18127
18128 c-=guysbuf[id].misc4;
18129 ret++;
18130 }
18131 }
18132 break;
18133
18134
18135 case eePATRA:
18136 {
18137 id &= 0xFFF;
18138 int32_t outeyes = 0;
18139
18140 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18141 {
18142 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18143 {
18144 al_trace("Patra outer eye %d could not be created!\n",i+1);
18145
18146 for(int32_t j=0; j<i+1; j++)
18147 guys.del(guys.Count()-1);
18148
18149 return 0;
18150 }
18151 else
18152 outeyes++;
18153
18154 ret++;
18155 }
18156
18157 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18158 {
18159 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18160 {
18161 al_trace("Patra inner eye %d could not be created!\n",i+1);
18162
18163 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18164 guys.del(guys.Count()-1);
18165
18166 return 0;
18167 }
18168
18169 ret++;
18170 }
18171
18172 break;
18173 }
18174 }
18175
18176 893 return ret;
18177 893 }
18178
18179 // Returns number of enemies/segments created
18180 52935 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
18181 {
18182 //zprint2("addenemy id is: %d\n", (id&0xFFF));
18183 52935 int32_t realid = id&0xFFF;
18184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52935 times.
52935 if( realid > MAXGUYS )
18185 {
18186 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
18187 return 0;
18188 }
18189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52935 times.
52935 if(id <= 0) return 0;
18190
18191 52935 int32_t ret = 0;
18192 52935 sprite *e=NULL;
18193
18194
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26743 times.
✓ Branch 4 taken 1694 times.
✓ Branch 5 taken 2941 times.
✓ Branch 6 taken 1048 times.
✓ Branch 7 taken 1605 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 5764 times.
✓ Branch 10 taken 2135 times.
✓ Branch 11 taken 2257 times.
✓ Branch 12 taken 523 times.
✓ Branch 13 taken 76 times.
✓ Branch 14 taken 94 times.
✓ Branch 15 taken 58 times.
✓ Branch 16 taken 94 times.
✓ Branch 17 taken 55 times.
✓ Branch 18 taken 239 times.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 413 times.
✓ Branch 21 taken 374 times.
✓ Branch 22 taken 4900 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 256 times.
✓ Branch 25 taken 889 times.
✓ Branch 26 taken 141 times.
✓ Branch 27 taken 246 times.
✓ Branch 28 taken 56 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 90 times.
52935 switch(guysbuf[id&0xFFF].family)
18195 {
18196 //Fixme: possible enemy memory leak. (minor)
18197 case eeWALK:
18198
3/6
✓ Branch 0 taken 26743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26743 times.
✗ Branch 5 not taken.
26743 e = new eStalfos((zfix)x,(zfix)y,id,clk);
18199 26743 break;
18200
18201 case eeLEV:
18202
3/6
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1694 times.
✗ Branch 5 not taken.
1694 e = new eLeever((zfix)x,(zfix)y,id,clk);
18203 1694 break;
18204
18205 case eeTEK:
18206
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
2941 e = new eTektite((zfix)x,(zfix)y,id,clk);
18207 2941 break;
18208
18209 case eePEAHAT:
18210
3/6
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
1048 e = new ePeahat((zfix)x,(zfix)y,id,clk);
18211 1048 break;
18212
18213 case eeZORA:
18214
3/6
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1605 times.
✗ Branch 5 not taken.
1605 e = new eZora((zfix)x,(zfix)y,id,clk);
18215 1605 break;
18216
18217 case eeGHINI:
18218
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eGhini((zfix)x,(zfix)y,id,clk);
18219 140 break;
18220
18221 case eeKEESE:
18222
3/6
✓ Branch 0 taken 5764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5764 times.
✗ Branch 5 not taken.
5764 e = new eKeese((zfix)x,(zfix)y,id,clk);
18223 5764 break;
18224
18225 case eeWIZZ:
18226
3/6
✓ Branch 0 taken 2135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2135 times.
✗ Branch 5 not taken.
2135 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
18227 2135 break;
18228
18229 case eePROJECTILE:
18230
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
2257 e = new eProjectile((zfix)x,(zfix)y,id,clk);
18231 2257 break;
18232
18233 case eeWALLM:
18234
3/6
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
523 e = new eWallM((zfix)x,(zfix)y,id,clk);
18235 523 break;
18236
18237 case eeAQUA:
18238
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
18239 76 break;
18240
18241 case eeMOLD:
18242
6/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 94 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18243 94 break;
18244
18245 case eeMANHAN:
18246
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
58 e = new eManhandla((zfix)x,(zfix)y,id,clk);
18247 58 break;
18248
18249 case eeGLEEOK:
18250
6/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 94 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18251 94 break;
18252
18253 case eeGHOMA:
18254
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 e = new eGohma((zfix)x,(zfix)y,id,clk);
18255 55 break;
18256
18257 case eeLANM:
18258
6/12
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 239 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 239 times.
✓ Branch 10 taken 239 times.
✗ Branch 11 not taken.
239 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
18259 239 break;
18260
18261 case eeGANON:
18262
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 e = new eGanon((zfix)x,(zfix)y,id,clk);
18263 10 break;
18264
18265 case eeFAIRY:
18266
3/6
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
413 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
18267 413 break;
18268
18269 case eeFIRE:
18270
3/6
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
374 e = new eFire((zfix)x,(zfix)y,id,clk);
18271 374 break;
18272
18273 case eeOTHER:
18274
3/6
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4900 times.
✗ Branch 5 not taken.
4900 e = new eOther((zfix)x,(zfix)y,id,clk);
18275 4900 break;
18276
18277
18278 case eeSCRIPT01:
18279 case eeSCRIPT02:
18280 case eeSCRIPT03:
18281 case eeSCRIPT04:
18282 case eeSCRIPT05:
18283 case eeSCRIPT06:
18284 case eeSCRIPT07:
18285 case eeSCRIPT08:
18286 case eeSCRIPT09:
18287 case eeSCRIPT10:
18288 case eeSCRIPT11:
18289 case eeSCRIPT12:
18290 case eeSCRIPT13:
18291 case eeSCRIPT14:
18292 case eeSCRIPT15:
18293 case eeSCRIPT16:
18294 case eeSCRIPT17:
18295 case eeSCRIPT18:
18296 case eeSCRIPT19:
18297 case eeSCRIPT20:
18298 {
18299 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18300 {
18301 e = new eScript((zfix)x,(zfix)y,id,clk);
18302 break;
18303 }
18304 else return 0;
18305 }
18306
18307 case eeFFRIENDLY01:
18308 case eeFFRIENDLY02:
18309 case eeFFRIENDLY03:
18310 case eeFFRIENDLY04:
18311 case eeFFRIENDLY05:
18312 case eeFFRIENDLY06:
18313 case eeFFRIENDLY07:
18314 case eeFFRIENDLY08:
18315 case eeFFRIENDLY09:
18316 case eeFFRIENDLY10:
18317 {
18318 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18319 {
18320 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
18321 }
18322 else return 0;
18323
18324 }
18325
18326 case eeSPINTILE:
18327
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
18328 94 break;
18329
18330 // and these enemies use the misc10/misc2 value
18331 case eeROCK:
18332 {
18333
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 226 times.
256 switch(guysbuf[id&0xFFF].misc10)
18334 {
18335 case 1:
18336
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
18337 30 break;
18338
18339 226 case 0:
18340 default:
18341
3/6
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
226 e = new eRock((zfix)x,(zfix)y,id,clk);
18342 226 break;
18343 }
18344
18345 256 break;
18346 }
18347
18348 case eeTRAP:
18349 {
18350
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 742 times.
889 switch(guysbuf[id&0xFFF].misc2)
18351 {
18352 case 1:
18353
3/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
147 e = new eTrap2((zfix)x,(zfix)y,id,clk);
18354 147 break;
18355
18356 742 case 0:
18357 default:
18358
3/6
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 742 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 742 times.
✗ Branch 5 not taken.
742 e = new eTrap((zfix)x,(zfix)y,id,clk);
18359 742 break;
18360 }
18361
18362 889 break;
18363 }
18364
18365 case eeDONGO:
18366 {
18367
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 139 times.
141 switch(guysbuf[id&0xFFF].misc10)
18368 {
18369 case 1:
18370
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
18371 2 break;
18372
18373 139 case 0:
18374 default:
18375
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eDodongo((zfix)x,(zfix)y,id,clk);
18376 139 break;
18377 }
18378
18379 141 break;
18380 }
18381
18382 case eeDIG:
18383 {
18384
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 48 times.
246 switch(guysbuf[id&0xFFF].misc10)
18385 {
18386 case 1:
18387
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eLilDig((zfix)x,(zfix)y,id,clk);
18388 198 break;
18389
18390 48 case 0:
18391 default:
18392
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18393 48 break;
18394 }
18395
18396 246 break;
18397 }
18398
18399 case eePATRA:
18400 {
18401
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
56 switch(guysbuf[id&0xFFF].misc10)
18402 {
18403 case 1:
18404
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_qr(qr_HARDCODED_BS_PATRA))
18405 {
18406
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18407 3 break;
18408 }
18409 [[fallthrough]];
18410 53 case 0:
18411 default:
18412
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new ePatra((zfix)x,(zfix)y,id,clk);
18413 53 break;
18414 }
18415
18416 56 break;
18417 }
18418
18419 case eeGUY:
18420 {
18421 switch(guysbuf[id&0xFFF].misc10)
18422 {
18423 case 1:
18424 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18425 break;
18426
18427 case 0:
18428 default:
18429 e = new eNPC((zfix)x,(zfix)y,id,clk);
18430 break;
18431 }
18432
18433 break;
18434 }
18435
18436 case eeNONE:
18437
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(guysbuf[id&0xFFF].misc10 ==1)
18438 {
18439
3/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
90 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18440 90 break;
18441 break;
18442 }
18443 [[fallthrough]];
18444 default:
18445
18446 return 0;
18447 }
18448
18449 52935 ret++; // Made one enemy.
18450
18451
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
52935 if(z && canfall(id))
18452 {
18453 59 e->z = (zfix)z;
18454 59 }
18455
18456
2/2
✓ Branch 0 taken 52852 times.
✓ Branch 1 taken 83 times.
52935 ((enemy*)e)->ceiling = (z && canfall(id));
18457
18458
1/2
✓ Branch 0 taken 52935 times.
✗ Branch 1 not taken.
52935 if(!guys.add(e))
18459 {
18460 return 0;
18461 }
18462
18463 // add segments of segmented enemies
18464 52935 int32_t c=0;
18465
18466
6/6
✓ Branch 0 taken 52394 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 56 times.
52935 switch(guysbuf[id&0xFFF].family)
18467 {
18468 case eeMOLD:
18469 {
18470 94 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18471 94 id &= 0xFFF;
18472
18473
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 624 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 624 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 94 times.
624 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18474 {
18475 //christ this is messy -DD
18476 530 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18477
18478
4/8
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 530 times.
✗ Branch 7 not taken.
530 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18479 {
18480 al_trace("Moldorm segment %d could not be created!\n",i+1);
18481
18482 for(int32_t j=0; j<i+1; j++)
18483 guys.del(guys.Count()-1);
18484
18485 return 0;
18486 }
18487
18488
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 436 times.
530 if(i>0)
18489 436 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18490
18491 530 ret++;
18492 530 }
18493
18494 94 break;
18495 }
18496
18497 case eeLANM:
18498 {
18499 239 id &= 0xFFF;
18500 239 int32_t shft = guysbuf[id].misc2;
18501 239 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18502
18503
4/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
239 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18504 {
18505 al_trace("Lanmola segment 1 could not be created!\n");
18506 guys.del(guys.Count()-1);
18507 return 0;
18508 }
18509
18510 239 ret++;
18511
18512
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1250 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1250 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1250 times.
✓ Branch 6 taken 1011 times.
✓ Branch 7 taken 239 times.
1250 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18513 {
18514
4/8
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
1011 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18515 {
18516 al_trace("Lanmola segment %d could not be created!\n",i+1);
18517
18518 for(int32_t j=0; j<i+1; j++)
18519 guys.del(guys.Count()-1);
18520
18521 return 0;
18522 }
18523
18524 1011 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18525 1011 ret++;
18526 1011 }
18527 }
18528 239 break;
18529
18530 case eeMANHAN:
18531 58 id &= 0xFFF;
18532
18533
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18534 {
18535
4/8
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 264 times.
✗ Branch 7 not taken.
264 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18536 {
18537 al_trace("Manhandla head %d could not be created!\n",i+1);
18538
18539 for(int32_t j=0; j<i+1; j++)
18540 {
18541 guys.del(guys.Count()-1);
18542 }
18543
18544 return 0;
18545 }
18546
18547 264 ret++;
18548 264 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18549 264 }
18550
18551 58 break;
18552
18553 case eeGLEEOK:
18554 {
18555 94 id &= 0xFFF;
18556 94 eGleeok* parent = (eGleeok*)e;
18557
18558
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 362 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 362 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 94 times.
362 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18559 {
18560
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18561
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!guys.add(head))
18562 {
18563 al_trace("Gleeok head %d could not be created!\n",i+1);
18564
18565 for(int32_t j=0; j<i+1; j++)
18566 {
18567 guys.del(guys.Count()-1);
18568 }
18569
18570 return false;
18571 }
18572
18573 268 head->necktile=parent->necktile;
18574 268 head->dummy_int[1]=parent->necktile;
18575
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 73 times.
268 if(get_qr(qr_NEWENEMYTILES))
18576 {
18577 195 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18578 195 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18579 195 }
18580 else
18581 {
18582 73 head->dummy_int[2]=parent->necktile+1; //connected head tile
18583 73 head->dummy_int[3]=parent->necktile+2; //flying head tile
18584 }
18585 268 head->tile = head->dummy_int[2];
18586
18587 268 c-=guysbuf[id].misc4;
18588 268 ret++;
18589 268 }
18590 }
18591 94 break;
18592
18593
18594 case eePATRA:
18595 {
18596 56 id &= 0xFFF;
18597 56 int32_t outeyes = 0;
18598
18599
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 56 times.
498 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18600 {
18601
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 424 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 424 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 424 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
442 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18602 {
18603 al_trace("Patra outer eye %d could not be created!\n",i+1);
18604
18605 for(int32_t j=0; j<i+1; j++)
18606 guys.del(guys.Count()-1);
18607
18608 return 0;
18609 }
18610 else
18611 442 outeyes++;
18612
18613 442 ret++;
18614 442 }
18615
18616
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 56 times.
144 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18617 {
18618
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18619 {
18620 al_trace("Patra inner eye %d could not be created!\n",i+1);
18621
18622 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18623 guys.del(guys.Count()-1);
18624
18625 return 0;
18626 }
18627
18628 88 ret++;
18629 88 }
18630
18631 56 break;
18632 }
18633 }
18634
18635 52935 return ret;
18636 52935 }
18637
18638 1250383 bool isjumper(int32_t id)
18639 {
18640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1250383 times.
1250383 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18641 {
18642 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
18643 return false;
18644 }
18645
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1151282 times.
✓ Branch 2 taken 99097 times.
1250383 switch(guysbuf[id&0xFFF].family)
18646 {
18647 case eeROCK:
18648 case eeTEK:
18649 4 return true;
18650
18651 case eeWALK:
18652
3/4
✓ Branch 0 taken 99097 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 86832 times.
99097 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
18653 86832 }
18654
18655 1238114 return false;
18656 1250383 }
18657
18658
18659 115481 bool isfixedtogrid(int32_t id)
18660 {
18661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115481 times.
115481 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18662 {
18663 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
18664 return false;
18665 }
18666
1/2
✓ Branch 0 taken 115481 times.
✗ Branch 1 not taken.
115481 switch(guysbuf[id&0xFFF].family)
18667 {
18668 case eeWALK:
18669 case eeLEV:
18670 case eeZORA:
18671 case eeDONGO:
18672 case eeGANON:
18673 case eeROCK:
18674 case eeGLEEOK:
18675 case eeAQUA:
18676 case eeLANM:
18677 return true;
18678 }
18679
18680 115481 return false;
18681 115481 }
18682
18683 // Can't fall, can have Z value.
18684 30359352 bool isflier(int32_t id)
18685 {
18686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30359352 times.
30359352 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18687 {
18688 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
18689 return false;
18690 }
18691
2/2
✓ Branch 0 taken 27052185 times.
✓ Branch 1 taken 3307167 times.
30359352 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18692 {
18693 case eePEAHAT:
18694 case eeKEESE:
18695 case eePATRA:
18696 case eeFAIRY:
18697 case eeGHINI:
18698
18699 // Could theoretically have their Z set by a script
18700 case eeFIRE:
18701 3307167 return true;
18702 break;
18703 }
18704
18705 27052185 return false;
18706 30359352 }
18707
18708 // Can't have Z position
18709 2338642 bool never_in_air(int32_t id)
18710 {
18711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2338642 times.
2338642 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18712 {
18713 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
18714 return false;
18715 }
18716
2/2
✓ Branch 0 taken 2329094 times.
✓ Branch 1 taken 9548 times.
2338642 switch(guysbuf[id&0xFFF].family)
18717 {
18718 case eeMANHAN:
18719 case eeMOLD:
18720 case eeLANM:
18721 case eeGLEEOK:
18722 case eeZORA:
18723 case eeLEV:
18724 case eeAQUA:
18725 case eeROCK:
18726 case eeGANON:
18727 case eeTRAP:
18728 case eePROJECTILE:
18729 case eeSPINTILE:
18730 9548 return true;
18731 }
18732
18733 2329094 return false;
18734 2338642 }
18735
18736 1369433 bool canfall(int32_t id)
18737 {
18738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1369433 times.
1369433 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18739 {
18740 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
18741 return false;
18742 }
18743
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1369407 times.
✓ Branch 2 taken 26 times.
1369433 switch(guysbuf[id&0xFFF].family)
18744 {
18745 case eeGUY:
18746 {
18747
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
18748 26 return false;
18749
18750 switch(guysbuf[id&0xFFF].misc10)
18751 {
18752 case 1:
18753 case 2:
18754 return true;
18755
18756 case 0:
18757 case 3:
18758 default:
18759 return false;
18760 }
18761
18762 case eeGHOMA:
18763 case eeDIG:
18764 return false;
18765 }
18766 }
18767
18768
18769
4/4
✓ Branch 0 taken 1360973 times.
✓ Branch 1 taken 8434 times.
✓ Branch 2 taken 110590 times.
✓ Branch 3 taken 1250383 times.
1369407 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18770 1369433 }
18771
18772 31450266 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18773 {
18774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31450266 times.
31450266 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18775 {
18776 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
18777 return false;
18778 }
18779 //Z_scripterrlog("canfall family is %d:\n", family);
18780 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
18781 //if ( family == eeFIRE && id >= eSTART )
18782 //{
18783 // Z_scripterrlog("eeFire\n");
18784 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
18785 //}
18786
18787 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18788
18789
3/3
✓ Branch 0 taken 195032 times.
✓ Branch 1 taken 30214405 times.
✓ Branch 2 taken 1040829 times.
31450266 switch(guysbuf[id&0xFFF].family)
18790 {
18791 case eeGUY:
18792 {
18793
1/2
✓ Branch 0 taken 1040829 times.
✗ Branch 1 not taken.
1040829 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18794 1040829 return false;
18795
18796 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
18797 {
18798 case 1:
18799 case 2:
18800 return true;
18801
18802 case 0:
18803 case 3:
18804 default:
18805 return false;
18806 }
18807
18808 case eeGHOMA:
18809 case eeDIG:
18810 195032 return false;
18811 }
18812 }
18813
18814
2/2
✓ Branch 0 taken 21661215 times.
✓ Branch 1 taken 8553190 times.
30214405 if(!checkgrav) return true;
18815 21661215 return (moveflags & FLAG_OBEYS_GRAV);
18816
18817 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18818 // {
18819 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
18820 // else return false;
18821 // }
18822 // else
18823 // {
18824 // return (moveflags & FLAG_OBEYS_GRAV);
18825 // }
18826 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18827 31450266 }
18828
18829 758 void addfires()
18830 {
18831
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 336 times.
758 if(!get_qr(qr_NOGUYFIRES))
18832 {
18833 336 int32_t bs = get_qr(qr_BSZELDA);
18834 336 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18835 336 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18836 336 }
18837 758 }
18838
18839 16277 void loadguys()
18840 {
18841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16277 times.
16277 if(loaded_guys)
18842 return;
18843
18844 16277 loaded_guys=true;
18845
18846 16277 byte Guy=0;
18847 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18848 // Else use mITEM and ipONETIME
18849 16277 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18850 16277 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18851
18852 16277 repaircharge=0;
18853 16277 adjustmagic=false;
18854 16277 learnslash=false;
18855
18856
2/2
✓ Branch 0 taken 48831 times.
✓ Branch 1 taken 16277 times.
65108 for(int32_t i=0; i<3; i++)
18857 {
18858 48831 prices[i]=0;
18859 48831 }
18860
18861 16277 hasitem=0;
18862
18863 16277 mapscr* guyscr = tmpscr;
18864
4/4
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 15598 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 339 times.
16277 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18865 {
18866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(DMaps[currdmap].flags&dmfCAVES)
18867 {
18868 339 Guy=tmpscr[1].guy;
18869 339 guyscr = tmpscr+1;
18870 339 }
18871 339 }
18872 else
18873 {
18874 15938 Guy=tmpscr->guy;
18875
18876
4/4
✓ Branch 0 taken 15598 times.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 9437 times.
✓ Branch 3 taken 6161 times.
15938 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18877 6161 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18878 }
18879
18880 16277 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18881 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18882
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 13419 times.
✓ Branch 2 taken 2081 times.
✓ Branch 3 taken 777 times.
16277 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18883 {
18884
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 768 times.
777 if(tmpscr->room==rZELDA)
18885 {
18886 9 addguy(120,72,Guy,-15,true,guyscr);
18887 9 guys.spr(0)->hxofs=1000;
18888 9 addenemy(128,96,eFIRE,-15);
18889 9 addenemy(112,96,eFIRE,-15);
18890 9 addenemy(96,120,eFIRE,-15);
18891 9 addenemy(144,120,eFIRE,-15);
18892 9 return;
18893 }
18894
18895
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
1536 bool ffire = oldguy
18896
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 10 times.
768 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18897 : (guyscr->roomflags&RFL_GUYFIRES);
18898
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 758 times.
768 if(ffire)
18899 758 addfires();
18900
18901
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 335 times.
768 if(currscr>=128)
18902
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
347 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18903 12 Guy=0;
18904
18905
4/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 647 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
768 switch(tmpscr->room)
18906 {
18907 case rSP_ITEM:
18908 case rGRUMBLE:
18909 case rBOMBS:
18910 case rARROWS:
18911 case rSWINDLE:
18912 case rMUPGRADE:
18913 case rLEARNSLASH:
18914 case rTAKEONE:
18915
8/8
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
97 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18916 28 Guy=0;
18917
18918 137 break;
18919
18920 case rREPAIR:
18921 if (get_qr(qr_OLD_DOORREPAIR)) break;
18922 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18923 Guy=0;
18924
18925 break;
18926 case rRP_HC:
18927 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18928 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18929 Guy=0;
18930
18931 break;
18932 case rMONEY:
18933
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18934 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18935 Guy=0;
18936
18937 break;
18938
18939 case rTRIFORCE:
18940 {
18941 23 int32_t tc = TriforceCount();
18942
18943
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 12 times.
23 if(get_qr(qr_4TRI))
18944 {
18945
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18946 10 Guy=0;
18947 9 }
18948 else
18949 {
18950
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18951 12 Guy=0;
18952 }
18953 }
18954 21 break;
18955 }
18956
18957
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 708 times.
766 if(Guy)
18958 {
18959
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 698 times.
708 if(ffire)
18960 698 blockpath=true;
18961
18962
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 385 times.
708 if(currscr<128)
18963 385 sfx(WAV_SCALE);
18964
18965
4/4
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 382 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 323 times.
708 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18966 708 Hero.Freeze();
18967 708 }
18968 766 }
18969
3/6
✓ Branch 0 taken 15500 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15449 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15500 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18970 {
18971 51 sfx(WAV_SCALE);
18972 51 addguy(120,62,Guy,-14,false,guyscr);
18973 51 }
18974
18975 16266 loaditem();
18976
18977 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18978 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18979
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16256 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
16266 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18980 {
18981 //setmapflag();
18982
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 8 times.
88 for(int32_t i=0; i<10; i++)
18983 80 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18984 8 }
18985 16275 }
18986
18987 16282 void loaditem()
18988 {
18989 16282 byte Item = 0;
18990
18991
2/2
✓ Branch 0 taken 15603 times.
✓ Branch 1 taken 679 times.
16282 if(currscr<128)
18992 {
18993 15603 Item=tmpscr->item;
18994
18995
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 14805 times.
✓ Branch 2 taken 14228 times.
✓ Branch 3 taken 1375 times.
15603 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18996 {
18997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1375 times.
1375 if(tmpscr->flags8&fSECRETITEM)
18998 hasitem=8;
18999
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 746 times.
1375 else if(tmpscr->flags&fITEM)
19000 629 hasitem=1;
19001
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 712 times.
746 else if(tmpscr->enemyflags&efCARRYITEM)
19002 34 hasitem=4; // Will be set to 2 by roaming_item
19003 else
19004
2/4
✓ Branch 0 taken 712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 712 times.
✗ Branch 3 not taken.
1424 items.add(new item((zfix)tmpscr->itemx,
19005
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 712 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 712 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 712 times.
✗ Branch 13 not taken.
712 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19006
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 709 times.
✗ Branch 9 not taken.
712 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19007
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 650 times.
712 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
19008 712 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19009 1375 }
19010 15603 }
19011
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 else if(!(DMaps[currdmap].flags&dmfCAVES))
19012 {
19013
4/6
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
341 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
19014
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 109 times.
340 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
19015 {
19016 110 Item=tmpscr[1].catchall;
19017
19018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Item)
19019
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
220 items.add(new item((zfix)tmpscr->itemx,
19020
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 110 times.
✗ Branch 13 not taken.
110 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19021
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
110 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19022 110 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19023 110 }
19024 340 }
19025 16282 }
19026
19027 539 void never_return(int32_t index)
19028 {
19029
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 130 times.
539 if(!get_qr(qr_KILLALL))
19030 130 goto doit;
19031
19032
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 201 times.
1541 for(int32_t i=0; i<guys.Count(); i++)
19033
4/4
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 306 times.
1340 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
19034 {
19035 208 goto dontdoit;
19036 201 }
19037
19038 doit:
19039 331 setmapflag(mNEVERRET);
19040 dontdoit:
19041 539 return;
19042 }
19043
19044 36941 bool slowguy(int32_t id)
19045 {
19046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36941 times.
36941 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19047 {
19048 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
19049 return false;
19050 }
19051 //return (guysbuf[id].step<100);
19052
2/2
✓ Branch 0 taken 31378 times.
✓ Branch 1 taken 5563 times.
36941 switch(id)
19053 {
19054 case eOCTO1S:
19055 case eOCTO2S:
19056 case eOCTO1F:
19057 case eOCTO2F:
19058 case eLEV1:
19059 case eLEV2:
19060 case eROCK:
19061 case eBOULDER:
19062 5563 return true;
19063 }
19064
19065 31378 return false;
19066 36941 }
19067
19068 41698 bool ok2add(int32_t id)
19069 {
19070
2/4
✓ Branch 0 taken 41698 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41698 times.
41698 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
19071 {
19072 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
19073 return false;
19074 }
19075
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 41290 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 218 times.
41698 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
19076 218 return false;
19077
19078
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41325 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 92 times.
41480 switch(guysbuf[id].family)
19079 {
19080 // I added a special case for shooters because having traps on the same screen
19081 // was preventing them from spawning due to TMPNORET. This means they will
19082 // never stay dead, though, so it may not be the best solution. - Saf
19083 case eePROJECTILE:
19084 63 return true;
19085
19086
19087 case eeDIG:
19088 {
19089
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 47 times.
92 switch(guysbuf[id].misc10)
19090 {
19091 case 1:
19092
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_qr(qr_NOTMPNORET))
19093 13 return !getmapflag(mTMPNORET);
19094
19095 32 return true;
19096
19097 47 case 0:
19098 default:
19099 47 return true;
19100 }
19101 }
19102 case eeGANON:
19103 case eeTRAP:
19104 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
19105 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
19106 [[fallthrough]];
19107 default:
19108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41325 times.
41325 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
19109 41325 break;
19110 }
19111
19112
2/2
✓ Branch 0 taken 14321 times.
✓ Branch 1 taken 27004 times.
41325 if(!get_qr(qr_NOTMPNORET))
19113 27004 return !getmapflag(mTMPNORET);
19114
19115 14321 return true;
19116 41698 }
19117
19118 402634 void activate_fireball_statue(int32_t pos)
19119 {
19120
3/4
✓ Branch 0 taken 113289 times.
✓ Branch 1 taken 289345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113289 times.
402634 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
19121 {
19122 289345 return;
19123 }
19124
19125 113289 int32_t cx=-1000, cy=-1000;
19126 113289 int32_t x = (pos&15)<<4;
19127 113289 int32_t y = pos&0xF0;
19128
19129 113289 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19130
19131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113289 times.
113289 if(!isfixedtogrid(statueID))
19132 {
19133
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 112292 times.
113289 if(ctype==cL_STATUE)
19134 {
19135 997 cx=x+4;
19136 997 cy=y+7;
19137 997 }
19138
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 111276 times.
112292 else if(ctype==cR_STATUE)
19139 {
19140 1016 cx=x-8;
19141 1016 cy=y-1;
19142 1016 }
19143
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 179 times.
111276 else if(ctype==cC_STATUE)
19144 {
19145 179 cx=x;
19146 179 cy=y;
19147 179 }
19148 113289 }
19149 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
19150 {
19151 cx=x;
19152 cy=y;
19153 }
19154
19155
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 2192 times.
113289 if(cx!=-1000) // No point creating it if this is false
19156 {
19157
2/2
✓ Branch 0 taken 6281 times.
✓ Branch 1 taken 2192 times.
8473 for(int32_t j=0; j<guys.Count(); j++)
19158 {
19159
3/4
✓ Branch 0 taken 1171 times.
✓ Branch 1 taken 5110 times.
✓ Branch 2 taken 1171 times.
✗ Branch 3 not taken.
6281 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
19160 {
19161 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
19162 return; // No point deleting it. A script might be toying with it in some way.
19163 else
19164 guys.del(j);
19165 }
19166 6281 }
19167
19168 2192 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
19169 2192 }
19170 402634 }
19171
19172 16137 void activate_fireball_statues()
19173 {
19174
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 15519 times.
16137 if(!(tmpscr->enemyflags&efFIREBALLS))
19175 {
19176 15519 return;
19177 }
19178
19179
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 108768 times.
109386 for(int32_t i=0; i<176; i++)
19180 {
19181 108768 activate_fireball_statue(i);
19182 108768 }
19183 16137 }
19184
19185 16137 void load_default_enemies()
19186 {
19187 16137 wallm_load_clk=frame-80;
19188
19189
2/2
✓ Branch 0 taken 15105 times.
✓ Branch 1 taken 1032 times.
16137 if(tmpscr->enemyflags&efZORA)
19190 {
19191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(zoraID>=0)
19192 1032 addenemy(-16, -16, zoraID, 0);
19193 1032 }
19194
19195
2/2
✓ Branch 0 taken 16034 times.
✓ Branch 1 taken 103 times.
16137 if(tmpscr->enemyflags&efTRAP4)
19196 {
19197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(cornerTrapID>=0)
19198 {
19199 103 addenemy(32, 32, cornerTrapID, -14);
19200 103 addenemy(208, 32, cornerTrapID, -14);
19201 103 addenemy(32, 128, cornerTrapID, -14);
19202 103 addenemy(208, 128, cornerTrapID, -14);
19203 103 }
19204 103 }
19205
19206
2/2
✓ Branch 0 taken 177507 times.
✓ Branch 1 taken 16137 times.
193644 for(int32_t y=0; y<176; y+=16)
19207 {
19208
2/2
✓ Branch 0 taken 2840112 times.
✓ Branch 1 taken 177507 times.
3017619 for(int32_t x=0; x<256; x+=16)
19209 {
19210 2840112 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19211 2840112 int32_t cflag = MAPFLAG(x, y);
19212 2840112 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19213
19214
4/6
✓ Branch 0 taken 2840112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840041 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840041 times.
2840112 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
19215 {
19216
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 61 times.
71 if(trapLOSHorizontalID>=0)
19217 61 addenemy(x, y, trapLOSHorizontalID, -14);
19218 71 }
19219
4/6
✓ Branch 0 taken 2840041 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840005 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840005 times.
2840041 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
19220 {
19221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(trapLOSVerticalID>=0)
19222 36 addenemy(x, y, trapLOSVerticalID, -14);
19223 36 }
19224
4/6
✓ Branch 0 taken 2840005 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839854 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839854 times.
2840005 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
19225 {
19226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(trapLOS4WayID>=0)
19227 {
19228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(addenemy(x, y, trapLOS4WayID, -14))
19229 151 guys.spr(guys.Count()-1)->dummy_int[1]=2;
19230 151 }
19231 151 }
19232
19233
4/6
✓ Branch 0 taken 2839854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839787 times.
✓ Branch 3 taken 67 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839787 times.
2839854 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
19234 {
19235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(trapConstantHorizontalID>=0)
19236 67 addenemy(x, y, trapConstantHorizontalID, -14);
19237 67 }
19238
4/6
✓ Branch 0 taken 2839787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839707 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839707 times.
2839787 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
19239 {
19240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
19241 80 addenemy(x, y, trapConstantVerticalID, -14);
19242 80 }
19243
19244
1/2
✓ Branch 0 taken 2840112 times.
✗ Branch 1 not taken.
2840112 if(ctype==cSPINTILE1)
19245 {
19246 // Awaken spinning tile
19247 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
19248 }
19249 2840112 }
19250 177507 }
19251
19252
2/2
✓ Branch 0 taken 16094 times.
✓ Branch 1 taken 43 times.
16137 if(tmpscr->enemyflags&efTRAP2)
19253 {
19254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(centerTrapID>=-1)
19255 {
19256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(64, 80, centerTrapID, -14))
19257 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19258
19259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(176, 80, centerTrapID, -14))
19260 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19261 43 }
19262 43 }
19263
19264
2/2
✓ Branch 0 taken 16070 times.
✓ Branch 1 taken 67 times.
16137 if(tmpscr->enemyflags&efROCKS)
19265 {
19266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(rockID>=0)
19267 {
19268 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19269 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19270 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19271 67 }
19272 67 }
19273
19274 16137 activate_fireball_statues();
19275 16137 }
19276
19277 20301471 void update_slope_combopos(int32_t lyr, int32_t pos)
19278 {
19279
2/4
✓ Branch 0 taken 20301471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20301471 times.
20301471 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
19280 20301471 mapscr* s = FFCore.tempScreens[lyr];
19281 20301471 newcombo const& cmb = combobuf[s->data[pos]];
19282
19283 20301471 auto id = (176*lyr)+pos;
19284 20301471 auto it = slopes.find(id);
19285
19286 20301471 bool wasSlope = it!=slopes.end();
19287 20301471 bool isSlope = cmb.type == cSLOPE;
19288
19289
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 20301378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
20301471 if(isSlope && !wasSlope)
19290 {
19291 93 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
19292 93 }
19293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20301378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20301378 else if(wasSlope && !isSlope)
19294 {
19295 slopes.erase(it);
19296 }
19297 20301471 }
19298 16292 void update_slope_comboposes()
19299 {
19300
2/2
✓ Branch 0 taken 114044 times.
✓ Branch 1 taken 16292 times.
130336 for(auto lyr = 0; lyr < 7; ++lyr)
19301 {
19302
2/2
✓ Branch 0 taken 20071744 times.
✓ Branch 1 taken 114044 times.
20185788 for(auto pos = 0; pos < 176; ++pos)
19303 20071744 update_slope_combopos(lyr,pos);
19304 114044 }
19305 16292 }
19306
19307 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19308 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19309 293866 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19310 {
19311 293866 delete_fireball_shooter(s, pos);
19312 293866 }
19313
19314 //Placeholder in case we need it.
19315 void screen_ffc_modify_preroutine(word index)
19316 {
19317 return;
19318 }
19319
19320 // Everything that must be done after we change a screen's combo to another combo. -L
19321 293866 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19322 {
19323 293866 s->valid |= mVALID;
19324 293866 activate_fireball_statue(pos);
19325
19326
2/2
✓ Branch 0 taken 293772 times.
✓ Branch 1 taken 94 times.
293866 if(combobuf[s->data[pos]].type==cSPINTILE1)
19327 {
19328 // Awaken spinning tile
19329 94 awaken_spinning_tile(s,pos);
19330 94 }
19331 293866 int32_t lyr = -1;
19332
2/2
✓ Branch 0 taken 89735 times.
✓ Branch 1 taken 204131 times.
293866 if(s == tmpscr) lyr = 0;
19333
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 479085 times.
543224 else for(size_t q = 0; q < 6; ++q)
19334 {
19335
2/2
✓ Branch 0 taken 25596 times.
✓ Branch 1 taken 453489 times.
479085 if(s == tmpscr2+q)
19336 {
19337 25596 lyr = q+1;
19338 25596 break;
19339 }
19340 453489 }
19341
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 229727 times.
293866 if(lyr > -1)
19342 229727 update_slope_combopos(lyr,pos);
19343 293866 }
19344
19345 4355642 void screen_ffc_modify_postroutine(word index)
19346 {
19347 4355642 ffcdata& ff = tmpscr->ffcs[index];
19348 4355642 newcombo const& cmb = combobuf[ff.getData()];
19349
19350 4355642 auto id = (176*7)+int32_t(index);
19351 4355642 auto it = slopes.find(id);
19352
19353 4355642 bool wasSlope = it!=slopes.end();
19354
1/2
✓ Branch 0 taken 4355642 times.
✗ Branch 1 not taken.
4355642 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
19355
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4355642 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4355642 if(isSlope && !wasSlope)
19356 {
19357 slopes.try_emplace(id, nullptr, &ff, id);
19358 }
19359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4355642 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4355642 else if(wasSlope && !isSlope)
19360 {
19361 slopes.erase(it);
19362 }
19363
19364 4355642 tmpscr->ffcCountMarkDirty();
19365 4355642 }
19366
19367 4320 void screen_combo_modify_pre(int32_t cid)
19368 {
19369
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19370 {
19371 30240 mapscr* t = FFCore.tempScreens[lyr];
19372
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19373 {
19374
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19375 {
19376 4395 screen_combo_modify_preroutine(t,i);
19377 4395 }
19378 5322240 }
19379 30240 }
19380 4320 }
19381 4320 void screen_combo_modify_post(int32_t cid)
19382 {
19383
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19384 {
19385 30240 mapscr* t = FFCore.tempScreens[lyr];
19386
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19387 {
19388
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19389 {
19390 4395 screen_combo_modify_postroutine(t,i);
19391 4395 }
19392 5322240 }
19393 30240 }
19394
2/2
✓ Branch 0 taken 552960 times.
✓ Branch 1 taken 4320 times.
557280 for(word ind = 0; ind < MAXFFCS; ++ind)
19395 {
19396
1/2
✓ Branch 0 taken 552960 times.
✗ Branch 1 not taken.
552960 if(tmpscr->ffcs[ind].getData() == cid)
19397 screen_ffc_modify_postroutine(ind);
19398 552960 }
19399 4320 }
19400
19401 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19402 {
19403
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19404 94 }
19405
19406
19407 // It stands for next_side_pos
19408 9987 void nsp(bool random)
19409 // moves sle_x and sle_y to the next position
19410 {
19411
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6726 times.
9987 if(random)
19412 {
19413
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19414 {
19415 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19416 1634 sle_y = (zc_oldrand()%10)*16;
19417 1634 }
19418 else
19419 {
19420 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19421 1627 sle_x = (zc_oldrand()%15)*16;
19422 }
19423
19424 3261 return;
19425 }
19426
19427
2/2
✓ Branch 0 taken 5084 times.
✓ Branch 1 taken 1642 times.
6726 if(sle_x==0)
19428 {
19429
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 146 times.
1642 if(sle_y<160)
19430 1496 sle_y+=16;
19431 else
19432 146 sle_x+=16;
19433 1642 }
19434
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 2962 times.
5084 else if(sle_y==160)
19435 {
19436
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 137 times.
2122 if(sle_x<240)
19437 1985 sle_x+=16;
19438 else
19439 137 sle_y-=16;
19440 2122 }
19441
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 1674 times.
2962 else if(sle_x==240)
19442 {
19443
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 123 times.
1288 if(sle_y>0)
19444 1165 sle_y-=16;
19445 else
19446 123 sle_x-=16;
19447 1288 }
19448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
1674 else if(sle_y==0)
19449 {
19450
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if(sle_x>0)
19451 1674 sle_x-=16;
19452 else
19453 sle_y+=16;
19454 1674 }
19455 9987 }
19456
19457 1932 int32_t next_side_pos(bool random)
19458 // moves sle_x and sle_y to the next available position
19459 // returns the direction the enemy should face
19460 {
19461 bool blocked;
19462 1932 int32_t c=0;
19463
19464 1932 do
19465 {
19466
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9862 times.
9987 nsp(c>35 ? false : random);
19467
3/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 8056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
11918 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19468
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19469
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931 times.
✗ Branch 3 not taken.
1931 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19470
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
1931 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19471 1931 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19472
19473
2/2
✓ Branch 0 taken 9986 times.
✓ Branch 1 taken 1 times.
9987 if(++c>50)
19474 1 return -1;
19475
2/2
✓ Branch 0 taken 8055 times.
✓ Branch 1 taken 1931 times.
9986 }
19476 9986 while(blocked);
19477
19478 1931 int32_t dir=0;
19479
19480
2/2
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 577 times.
1931 if(sle_x==0) dir=right;
19481
19482
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 501 times.
1931 if(sle_y==0) dir=down;
19483
19484
2/2
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 542 times.
1931 if(sle_x==240) dir=left;
19485
19486
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(sle_y==168) dir=up;
19487
19488 1931 return dir;
19489 1932 }
19490
19491 bool can_side_load(int32_t id)
19492 {
19493 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19494 {
19495 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
19496 return false;
19497 }
19498 switch(guysbuf[id].family) //id&0x0FFF)
19499 {
19500 //case eTEK1:
19501 //case eTEK2:
19502 //case eTEK3:
19503 //case eLEV1:
19504 //case eLEV2:
19505 //case eLEV3:
19506 //case eRAQUAM:
19507 //case eLAQUAM:
19508 //case eDODONGO:
19509 //case eMANHAN:
19510 //case eGLEEOK1:
19511 //case eGLEEOK2:
19512 //case eGLEEOK3:
19513 //case eGLEEOK4:
19514 //case eDIG1:
19515 //case eDIG3:
19516 //case eGOHMA1:
19517 //case eGOHMA2:
19518 //case eCENT1:
19519 //case eCENT2:
19520 //case ePATRA1:
19521 //case ePATRA2:
19522 //case eGANON:
19523 //case eMANHAN2:
19524 //case eCEILINGM: later
19525 //case eFLOORM: later
19526 //case ePATRABS:
19527 //case ePATRAL2:
19528 //case ePATRAL3:
19529 //case eGLEEOK1F:
19530 //case eGLEEOK2F:
19531 //case eGLEEOK3F:
19532 //case eGLEEOK4F:
19533 //case eDODONGOBS:
19534 //case eDODONGOF:
19535 //case eGOHMA3:
19536 //case eGOHMA4:
19537 //case eSHOOTMAGIC:
19538 //case eSHOOTROCK:
19539 //case eSHOOTSPEAR:
19540 //case eSHOOTSWORD:
19541 //case eSHOOTFLAME:
19542 //case eSHOOTFLAME2:
19543 //case eSHOOTFBALL:
19544 case eeTEK:
19545 case eeLEV:
19546 case eeAQUA:
19547 case eeDONGO:
19548 case eeMANHAN:
19549 case eeGLEEOK:
19550 case eeDIG:
19551 case eeGHOMA:
19552 case eeLANM:
19553 case eePATRA:
19554 case eeGANON:
19555 case eePROJECTILE:
19556 return false;
19557 break;
19558 }
19559
19560 return true;
19561 }
19562
19563 static bool script_sle = false;
19564 static int32_t sle_pattern = 0;
19565 void script_side_load_enemies()
19566 {
19567 if(script_sle || sle_clk) return;
19568 sle_cnt = 0;
19569 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19570 ++sle_cnt;
19571 script_sle = true;
19572 sle_pattern = tmpscr->pattern;
19573 sle_clk = 0;
19574 }
19575
19576 42952 void side_load_enemies()
19577 {
19578
3/4
✓ Branch 0 taken 42952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 578 times.
42952 if(!script_sle && sle_clk==0)
19579 {
19580 578 sle_pattern = tmpscr->pattern;
19581 578 sle_cnt = 0;
19582 578 int32_t guycnt = 0;
19583 578 int16_t s = (currmap<<7)+currscr;
19584 578 bool beenhere=false;
19585 578 bool reload=true;
19586 578 bool unbeatablereload = true;
19587
19588 578 load_default_enemies();
19589
19590
2/2
✓ Branch 0 taken 3468 times.
✓ Branch 1 taken 578 times.
4046 for(int32_t i=0; i<6; i++)
19591
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 178 times.
3646 if(visited[i]==s)
19592 178 beenhere=true;
19593
19594
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 400 times.
578 if(!beenhere)
19595 {
19596 400 visited[vhead]=s;
19597 400 vhead = (vhead+1)%6;
19598 400 }
19599
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 39 times.
178 else if(game->guys[s]==0)
19600 {
19601 39 sle_cnt=0;
19602 39 reload=false;
19603 39 }
19604
19605
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 539 times.
578 if(reload)
19606 {
19607 539 sle_cnt = game->guys[s];
19608
19609
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 177 times.
539 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19610 539 || sle_cnt==0)
19611 {
19612
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 177 times.
983 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19613 806 ++sle_cnt;
19614 177 }
19615
3/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 400 times.
✗ Branch 3 not taken.
539 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19616 {
19617 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19618 {
19619 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
19620 {
19621 unbeatablereload = false;
19622 }
19623 }
19624 if (unbeatablereload)
19625 {
19626 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19627 {
19628 ++sle_cnt;
19629 }
19630 }
19631 }
19632 539 }
19633
19634
2/4
✓ Branch 0 taken 578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 578 times.
578 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19635 {
19636 sle_cnt = 0;
19637
19638 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19639 ++sle_cnt;
19640 }
19641
19642
2/2
✓ Branch 0 taken 1889 times.
✓ Branch 1 taken 578 times.
2467 for(int32_t i=0; i<sle_cnt; i++)
19643 1889 ++guycnt;
19644
19645 578 game->guys[s] = guycnt;
19646 578 }
19647
19648
2/2
✓ Branch 0 taken 41020 times.
✓ Branch 1 taken 1932 times.
42952 if((++sle_clk+8)%24 == 0)
19649 {
19650 1932 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19651
19652
4/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 1739 times.
1932 if(dir==-1 || tooclose(sle_x,sle_y,32))
19653 {
19654 193 return;
19655 }
19656
19657 1739 int32_t enemy_slot=guys.Count();
19658
19659
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1739 times.
1739 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19660 sle_cnt--;
19661
19662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(sle_cnt > 0)
19663 {
19664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19665 {
19666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19667 {
19668 1739 guys.spr(enemy_slot)->dir = dir;
19669 1739 }
19670
1/2
✓ Branch 0 taken 1739 times.
✗ Branch 1 not taken.
1739 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19671 {
19672 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19673 {
19674 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19675 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19676 }
19677 }
19678 1739 }
19679 1739 }
19680 1739 }
19681
19682
2/2
✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 511 times.
42759 if(sle_cnt<=0)
19683 {
19684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 if(script_sle)
19685 script_sle = false;
19686 511 else loaded_enemies=true;
19687 511 sle_clk = 0;
19688 511 }
19689 42952 }
19690
19691 1125375 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19692 {
19693
19694
4/4
✓ Branch 0 taken 1025601 times.
✓ Branch 1 taken 99774 times.
✓ Branch 2 taken 99774 times.
✓ Branch 3 taken 1125375 times.
1125375 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19695 {
19696 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
19697 199548 return false; //never 0, never OoB.
19698 }
19699 // No corner enemies
19700
6/6
✓ Branch 0 taken 964628 times.
✓ Branch 1 taken 160747 times.
✓ Branch 2 taken 38801 times.
✓ Branch 3 taken 1003429 times.
✓ Branch 4 taken 110860 times.
✓ Branch 5 taken 88688 times.
1125375 if((x==0 || x==240) && (y==0 || y==160))
19701
19702 199548 return false;
19703
19704 //Is a no spawn combo...
19705
3/4
✓ Branch 0 taken 1003425 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1003425 times.
1003429 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19706 4 return false;
19707
19708 // No enemies in dungeon walls
19709
10/10
✓ Branch 0 taken 632806 times.
✓ Branch 1 taken 370619 times.
✓ Branch 2 taken 561286 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 489766 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 403942 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 318118 times.
1003425 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19710 314688 return false;
19711
19712 // Too close
19713
4/4
✓ Branch 0 taken 69962 times.
✓ Branch 1 taken 618775 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 69939 times.
688737 if(tooclose(x,y,40) && t<11)
19714 69939 return false;
19715
19716 // Can't fly onto it?
19717
4/4
✓ Branch 0 taken 115623 times.
✓ Branch 1 taken 503175 times.
✓ Branch 2 taken 34519 times.
✓ Branch 3 taken 16220 times.
669537 if(isflier(tmpscr->enemy[i])&&
19718
2/2
✓ Branch 0 taken 115367 times.
✓ Branch 1 taken 256 times.
115623 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19719
2/2
✓ Branch 0 taken 50739 times.
✓ Branch 1 taken 64628 times.
115367 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19720 16476 return false;
19721
19722 // Can't jump onto it?
19723 if
19724 (
19725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84754 times.
687076 guysbuf[tmpscr->enemy[i]].family==eeTEK
19726
19727
2/2
✓ Branch 0 taken 84754 times.
✓ Branch 1 taken 517568 times.
602322 &&
19728 (
19729
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19730
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOENEMY||
19731
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 ispitfall(x+8,y+8)||
19732
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 MAPFLAG(x+8,y+8)==mfNOENEMY||
19733 84754 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19734 )
19735 )
19736 {
19737 return false;
19738 }
19739
19740 // Other off-limit combos
19741
6/6
✓ Branch 0 taken 503175 times.
✓ Branch 1 taken 99147 times.
✓ Branch 2 taken 418421 times.
✓ Branch 3 taken 84754 times.
✓ Branch 4 taken 239150 times.
✓ Branch 5 taken 179271 times.
1020743 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19742
2/2
✓ Branch 0 taken 242813 times.
✓ Branch 1 taken 175608 times.
418421 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19743 418421 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19744 179271 return false;
19745
19746 // Don't ever generate enemies on these combos!
19747
3/4
✓ Branch 0 taken 422752 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422752 times.
423051 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19748 299 return false;
19749
19750 //BS Dodongos need at least 2 spaces.
19751
4/4
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 421788 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 2 times.
422752 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
19752 {
19753
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19754 ((x>224)||_walkflag(x+16,y+8, 2))&&
19755 ((y<16) ||_walkflag(x, y-8, 2))&&
19756 ((y>144)||_walkflag(x, y+24,2)))
19757 {
19758 return false;
19759 }
19760 2 }
19761
19762 422752 return true;
19763 1025601 }
19764
19765 79302 bool is_ceiling_pattern(int32_t i)
19766 {
19767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79302 times.
79302 return (i==pCEILING || i==pCEILINGR);
19768 }
19769
19770 5543 int32_t placeenemy(int32_t i)
19771 {
19772 5543 std::map<int32_t, int32_t> freeposcache;
19773 5543 int32_t frees = 0;
19774
19775
2/2
✓ Branch 0 taken 60973 times.
✓ Branch 1 taken 5543 times.
66516 for(int32_t y=0; y<176; y+=16)
19776 {
19777
2/2
✓ Branch 0 taken 975568 times.
✓ Branch 1 taken 60973 times.
1036541 for(int32_t x=0; x<256; x+=16)
19778 {
19779
3/4
✓ Branch 0 taken 975568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 391343 times.
✓ Branch 3 taken 584225 times.
975568 if(is_starting_pos(i,x,y,0))
19780 {
19781
1/2
✓ Branch 0 taken 391343 times.
✗ Branch 1 not taken.
391343 freeposcache[frees++] = (y&0xF0)+(x>>4);
19782 391343 }
19783 975568 }
19784 60973 }
19785
19786
2/2
✓ Branch 0 taken 5532 times.
✓ Branch 1 taken 11 times.
5543 if(frees > 0)
19787
2/4
✓ Branch 0 taken 5532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5532 times.
✗ Branch 3 not taken.
5532 return freeposcache[zc_oldrand()%frees];
19788
19789 11 return -1;
19790 5543 }
19791
19792 39968 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19793 {
19794 39968 bool placed=false;
19795 39968 int32_t t=-1;
19796
19797 // First: enemy combo flags
19798
2/2
✓ Branch 0 taken 424408 times.
✓ Branch 1 taken 36952 times.
461360 for(int32_t sy=0; sy<176; sy+=16)
19799 {
19800
2/2
✓ Branch 0 taken 6768277 times.
✓ Branch 1 taken 421392 times.
7189669 for(int32_t sx=0; sx<256; sx+=16)
19801 {
19802 6768277 int32_t cflag = MAPFLAG(sx, sy);
19803 6768277 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19804
19805
2/4
✓ Branch 0 taken 6768277 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6768277 times.
✗ Branch 3 not taken.
6768277 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19806 {
19807 if(!ok2add(tmpscr->enemy[i]))
19808 {
19809 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19810 }
19811 else
19812 {
19813 addenemy(sx,
19814 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19815 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19816
19817 ++guycnt;
19818
19819 placed=true;
19820 goto placed_enemy;
19821 }
19822 }
19823
19824
4/4
✓ Branch 0 taken 6765259 times.
✓ Branch 1 taken 3018 times.
✓ Branch 2 taken 6765259 times.
✓ Branch 3 taken 3018 times.
6768277 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19825 {
19826
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3016 times.
3018 if(!ok2add(tmpscr->enemy[i]))
19827 {
19828
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19829 2 }
19830 else
19831 {
19832 6032 addenemy(sx,
19833
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19835
19836 3016 ++guycnt;
19837
19838 3016 placed=true;
19839 3016 goto placed_enemy;
19840 }
19841 2 }
19842 6765261 }
19843 421392 }
19844
19845 // Next: enemy pattern
19846
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 32060 times.
✓ Branch 2 taken 31494 times.
✓ Branch 3 taken 5458 times.
✓ Branch 4 taken 31494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31494 times.
36952 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19847 {
19848 31494 do
19849 {
19850
19851 // NES positions
19852 50118 pos%=9;
19853 50118 x=stx[loadside][pos];
19854 50118 y=sty[loadside][pos];
19855 50118 ++pos;
19856 50118 ++t;
19857
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 31494 times.
81612 }
19858
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 50033 times.
50118 while((t< 20) && !is_starting_pos(i,x,y,t));
19859 31494 }
19860
19861
4/4
✓ Branch 0 taken 31494 times.
✓ Branch 1 taken 5458 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 31409 times.
36952 if(t<0 || t >= 20) // above enemy pattern failed
19862 {
19863 // Final chance: find a random position anywhere onscreen
19864 5543 int32_t randpos = placeenemy(i);
19865
19866
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5532 times.
5543 if(randpos>-1)
19867 {
19868 5532 x=(randpos&15)<<4;
19869 5532 y= randpos&0xF0;
19870 5532 }
19871 else // All opportunities failed - abort
19872 {
19873 11 return;
19874 }
19875 5532 }
19876
19877 {
19878 36941 int32_t c=0;
19879 36941 c=clk;
19880
19881
2/2
✓ Branch 0 taken 5563 times.
✓ Branch 1 taken 31378 times.
36941 if(!slowguy(tmpscr->enemy[i]))
19882 31378 ++fastguys;
19883
2/2
✓ Branch 0 taken 851 times.
✓ Branch 1 taken 4712 times.
5563 else if(fastguys>0)
19884 851 c=-15*(i-fastguys+2);
19885 else
19886 4712 c=-15*(i+1);
19887
19888
4/6
✓ Branch 0 taken 7803 times.
✓ Branch 1 taken 29138 times.
✓ Branch 2 taken 7803 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7803 times.
36941 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19889 {
19890 // Special case for blue leevers
19891
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7801 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
7803 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
19892 2 c=-15*(i+1);
19893 else
19894 7801 c=-15;
19895 7803 }
19896
19897
2/2
✓ Branch 0 taken 36635 times.
✓ Branch 1 taken 306 times.
36941 if(!ok2add(tmpscr->enemy[i]))
19898 {
19899
4/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
306 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19900 306 }
19901 else
19902 {
19903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36635 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19904 {
19905
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36552 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
73270 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19906
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
36635 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19907
19908 36635 ++guycnt;
19909 36635 }
19910 }
19911
19912 36941 placed=true;
19913 36941 } // if(t < 20)
19914
19915 placed_enemy:
19916
19917 // I don't like this, but it seems to work...
19918 static bool foundCarrier;
19919
19920
2/2
✓ Branch 0 taken 30369 times.
✓ Branch 1 taken 9588 times.
39957 if(i==0)
19921 9588 foundCarrier=false;
19922
19923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39957 times.
39957 if(placed)
19924 {
19925
4/4
✓ Branch 0 taken 9588 times.
✓ Branch 1 taken 30369 times.
✓ Branch 2 taken 9445 times.
✓ Branch 3 taken 143 times.
39957 if(i==0 && tmpscr->enemyflags&efLEADER)
19926 {
19927 143 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19928
19929
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 7 times.
143 if(index!=-1)
19930 {
19931 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
136 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(index!=-1)
19934 {
19935 136 ((enemy*)guys.spr(index))->leader = true;
19936 136 }
19937 136 }
19938 143 }
19939
19940
4/4
✓ Branch 0 taken 39857 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 39823 times.
✓ Branch 3 taken 34 times.
39957 if(!foundCarrier && hasitem&(4|2))
19941 {
19942 34 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19943
19944
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
19945 {
19946 34 ((enemy*)guys.spr(index))->itemguy = true;
19947 34 foundCarrier=true;
19948 34 }
19949 34 }
19950 39957 }
19951 39968 }
19952
19953 bool scriptloadenemies()
19954 {
19955 loaded_enemies = true;
19956 if(script_sle || sle_clk) return false;
19957 if(tmpscr->pattern==pNOSPAWN) return false;
19958
19959 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19960 {
19961 script_side_load_enemies();
19962 return true;
19963 }
19964
19965 int32_t pos=zc_oldrand()%9;
19966 int32_t clk=-15,x=0,y=0,fastguys=0;
19967 int32_t i=0,guycnt=0;
19968 int32_t loadcnt = 10;
19969
19970 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19971 {
19972 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19973 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19974 if (guys.Count() > preguycount)
19975 {
19976 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19977 {
19978 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19979 {
19980 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19981 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19982 }
19983 }
19984 }
19985 --clk;
19986 }
19987 return true;
19988 }
19989
19990 7245827 void loadenemies()
19991 {
19992
3/4
✓ Branch 0 taken 7245827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 7203453 times.
7245827 if(script_sle || sle_clk)
19993 {
19994 42374 side_load_enemies();
19995 42374 return;
19996 }
19997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7203453 times.
7203453 if(tmpscr->pattern==pNOSPAWN) return;
19998
2/2
✓ Branch 0 taken 7187246 times.
✓ Branch 1 taken 16207 times.
7203453 if(loaded_enemies)
19999 7187246 return;
20000
20001 // check if it's the dungeon boss and it has been beaten before
20002
4/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15959 times.
✓ Branch 2 taken 178 times.
✓ Branch 3 taken 70 times.
16207 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
20003 {
20004 70 loaded_enemies = true;
20005 70 return;
20006 }
20007
20008
4/4
✓ Branch 0 taken 15800 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 15559 times.
16137 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
20009 {
20010 578 side_load_enemies();
20011 578 return;
20012 }
20013
20014 15559 loaded_enemies=true;
20015
20016 // do enemies that are always loaded
20017 15559 load_default_enemies();
20018
20019 // dungeon basements
20020
20021 static byte dngn_enemy_x[4] = {32,96,144,208};
20022
20023
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 14880 times.
15559 if(currscr>=128)
20024 {
20025
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 if(DMaps[currdmap].flags&dmfCAVES) return;
20026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
20027 {
20028 for(int32_t i=0; i<10; i++)
20029 {
20030 if ( tmpscr->enemy[i] )
20031 {
20032 int32_t preguycount = guys.Count();
20033 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
20034 if (guys.Count() > preguycount)
20035 {
20036 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20037 {
20038 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20039 {
20040 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20041 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20042 }
20043 }
20044 }
20045 }
20046 }
20047 }
20048 else
20049 {
20050
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 340 times.
1700 for(int32_t i=0; i<4; i++)
20051 {
20052 1360 int32_t preguycount = guys.Count();
20053
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 396 times.
1360 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
20054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (guys.Count() > preguycount)
20055 {
20056
1/2
✓ Branch 0 taken 1360 times.
✗ Branch 1 not taken.
1360 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20057 {
20058 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20059 {
20060 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20061 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20062 }
20063 }
20064 1360 }
20065 1360 }
20066 }
20067 340 return;
20068 }
20069
20070 // check if it's been long enough to reload all enemies
20071
20072 14880 int32_t loadcnt = 10;
20073 14880 int16_t s = (currmap<<7)+currscr;
20074 14880 bool beenhere = false;
20075 14880 bool reload = true;
20076 14880 bool unbeatablereload = true;
20077
20078
2/2
✓ Branch 0 taken 89280 times.
✓ Branch 1 taken 14880 times.
104160 for(int32_t i=0; i<6; i++)
20079
2/2
✓ Branch 0 taken 84948 times.
✓ Branch 1 taken 4332 times.
93612 if(visited[i]==s)
20080 4332 beenhere = true;
20081
20082
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 10548 times.
14880 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
20083 {
20084 10548 visited[vhead]=s; //If not, it adds it to the array,
20085 10548 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
20086 10548 }
20087
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2331 times.
4332 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
20088 {
20089 2331 loadcnt = 0; //It will tell it not to load any enemies,
20090 2331 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
20091 2331 }
20092
20093
2/2
✓ Branch 0 taken 2331 times.
✓ Branch 1 taken 12549 times.
14880 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
20094 {
20095 12549 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
20096
20097
2/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 8300 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12549 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
20098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4249 times.
4249 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
20099 8300 loadcnt = 10; //That means all enemies need to be respawned.
20100
3/4
✓ Branch 0 taken 10548 times.
✓ Branch 1 taken 2001 times.
✓ Branch 2 taken 10548 times.
✗ Branch 3 not taken.
12549 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
20101 {
20102 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
20103 {
20104 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
20105 {
20106 unbeatablereload = false;
20107 }
20108 }
20109 if (unbeatablereload)
20110 {
20111 loadcnt = 10;
20112 }
20113 }
20114 12549 }
20115
20116
4/4
✓ Branch 0 taken 14230 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 14180 times.
14880 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
20117 700 loadcnt = 10; //All enemies also need to be respawned.
20118
20119 14880 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
20120 14880 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
20121 14880 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
20122
20123
4/4
✓ Branch 0 taken 6581 times.
✓ Branch 1 taken 48267 times.
✓ Branch 2 taken 39968 times.
✓ Branch 3 taken 14880 times.
54848 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
20124 {
20125 39968 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
20126 39968 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
20127
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 39651 times.
39968 if (guys.Count() > preguycount)
20128 {
20129
1/2
✓ Branch 0 taken 39651 times.
✗ Branch 1 not taken.
39651 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20130 {
20131 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20132 {
20133 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20134 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20135 }
20136 }
20137 39651 }
20138
20139 39968 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
20140 39968 }
20141
20142 14880 game->guys[s] = guycnt;
20143 //} //if(true)
20144 7245827 }
20145 147 void moneysign()
20146 {
20147 147 additem(48,108,iRupy,ipDUMMY);
20148 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
20149 147 set_clip_state(pricesdisplaybuf, 0);
20150 147 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
20151 147 }
20152
20153 1571 void putprices(bool sign)
20154 {
20155
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1565 times.
1571 if(fadeclk > 0) return;
20156 // refresh what's under the prices
20157 // for(int32_t i=5; i<12; i++)
20158 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
20159
20160 1565 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
20161 1565 int32_t step=32;
20162 1565 int32_t x=80;
20163
20164
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 1387 times.
1565 if(prices[2]==0)
20165 {
20166 1387 step<<=1;
20167
20168
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 27 times.
1387 if(prices[1]==0)
20169 {
20170 1360 x=112;
20171 1360 }
20172 1387 }
20173
20174
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 4695 times.
6260 for(int32_t i=0; i<3; i++)
20175 {
20176 // Kind of stupid, but it works: 100000 is used to indicate that an item
20177 // has a price of zero rather than there being no item.
20178 // 100000 isn't a valid price, so this doesn't cause problems.
20179
3/4
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 4003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
4695 if(prices[i]!=0 && prices[i]<100000)
20180 {
20181 char buf[8];
20182 692 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
20183
20184 692 int32_t l=(int32_t)strlen(buf);
20185 692 set_clip_state(pricesdisplaybuf, 0);
20186
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 671 times.
692 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
20187 692 }
20188
20189 4695 x+=step;
20190 4695 }
20191 1571 }
20192
20193 // Setting up special rooms
20194 // Also called when the Letter is used successfully.
20195 721 void setupscreen()
20196 {
20197 721 boughtsomething=false;
20198 721 int32_t t=currscr<128?0:1;
20199 721 word str=tmpscr[t].str;
20200
20201 // Prices are already set to 0 in dowarp()
20202
13/15
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 366 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
721 switch(tmpscr[t].room)
20203 {
20204 case rSP_ITEM: // special item
20205 105 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
20206 105 break;
20207
20208 case rINFO: // pay for info
20209 {
20210 14 int32_t count = 0;
20211 14 int32_t base = 88;
20212 14 int32_t step = 5;
20213
20214 14 moneysign();
20215
20216
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 for(int32_t i=0; i<3; i++)
20217 {
20218
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(QMisc.info[tmpscr[t].catchall].str[i])
20219 {
20220 42 ++count;
20221 42 }
20222 else
20223 break;
20224 42 }
20225
20226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(count)
20227 {
20228
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==1)
20229 {
20230 base = 88+32;
20231 }
20232
20233
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==2)
20234 {
20235 step = 6;
20236 }
20237
20238
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
56 for(int32_t i=0; i < count; i++)
20239 {
20240 42 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
20241 42 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20242 42 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
20243
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(prices[i]==0)
20244 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20245 42 int32_t itemid = current_item_id(itype_wealthmedal);
20246
20247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(itemid>=0 && prices[i]!=100000)
20248 {
20249 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20250 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20251 else
20252 prices[i]-=itemsbuf[itemid].misc1;
20253 prices[i]=vbound(prices[i], -99999, 0);
20254 if(prices[i]==0)
20255 prices[i]=100000;
20256 }
20257
20258
2/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
20259 prices[i]=-1;
20260 42 }
20261 14 }
20262
20263 14 break;
20264 }
20265
20266 case rMONEY: // secret money
20267 38 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
20268 38 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20269 38 break;
20270
20271 case rGAMBLE: // gambling
20272 7 prices[0]=prices[1]=prices[2]=-10;
20273 7 moneysign();
20274 7 additem(88,89,iRupy,ipMONEY+ipDUMMY);
20275 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20276 7 additem(120,89,iRupy,ipMONEY+ipDUMMY);
20277 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20278 7 additem(152,89,iRupy,ipMONEY+ipDUMMY);
20279 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
20280 7 break;
20281
20282 case rREPAIR: // door repair
20283
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20284 // }
20285 12 repaircharge=tmpscr[t].catchall;
20286 12 break;
20287
20288 case rMUPGRADE: // upgrade magic
20289 1 adjustmagic=true;
20290 1 break;
20291
20292 case rLEARNSLASH: // learn slash attack
20293 2 learnslash=true;
20294 2 break;
20295
20296 case rRP_HC: // heart container or red potion
20297 12 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
20298 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20299 12 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
20300 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20301 12 break;
20302
20303 case rP_SHOP: // potion shop
20304
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20305 {
20306 12 str=0;
20307 12 break;
20308 }
20309
20310 [[fallthrough]];
20311 case rTAKEONE: // take one
20312 case rSHOP: // shop
20313 {
20314 127 int32_t count = 0;
20315 127 int32_t base = 88;
20316 127 int32_t step = 5;
20317
20318
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 126 times.
127 if(tmpscr[t].room != rTAKEONE)
20319 126 moneysign();
20320
20321 //count and align the stuff
20322
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 363 times.
461 for(int32_t i=0; i<3; ++i)
20323 {
20324
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 29 times.
363 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20325 {
20326 334 ++count;
20327 334 }
20328 else
20329 {
20330 29 break;
20331 }
20332 334 }
20333
20334
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 18 times.
127 if(count==1)
20335 {
20336 18 base = 88+32;
20337 18 }
20338
20339
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 11 times.
127 if(count==2)
20340 {
20341 11 step = 6;
20342 11 }
20343
20344
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 127 times.
461 for(int32_t i=0; i<count; i++)
20345 {
20346 334 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20347 334 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20348
20349
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 332 times.
334 if(tmpscr[t].room != rTAKEONE)
20350 {
20351 332 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20352
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 if(prices[i]==0)
20353 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20354 332 int32_t itemid = current_item_id(itype_wealthmedal);
20355
20356
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
332 if(itemid>=0 && prices[i]!=100000)
20357 {
20358 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20359 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20360 else
20361 prices[i]+=itemsbuf[itemid].misc1;
20362 prices[i]=vbound(prices[i], 0, 99999);
20363 if(prices[i]==0)
20364 prices[i]=100000;
20365 }
20366
20367
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20368 prices[i]=1;
20369 332 }
20370 334 }
20371
20372 127 break;
20373 }
20374 case rBOTTLESHOP: // bottle shop
20375 {
20376 int32_t count = 0;
20377 int32_t base = 88;
20378 int32_t step = 5;
20379
20380 moneysign();
20381 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20382 //count and align the stuff
20383 for(int32_t i=0; i<3; ++i)
20384 {
20385 if(bst.fill[count] != 0)
20386 {
20387 ++count;
20388 }
20389 else
20390 {
20391 break;
20392 }
20393 }
20394
20395 if(count==1)
20396 {
20397 base = 88+32;
20398 }
20399
20400 if(count==2)
20401 {
20402 step = 6;
20403 }
20404
20405 for(int32_t i=0; i<count; i++)
20406 {
20407 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20408 //{ Setup dummy item
20409 item* curItem = ((item*)items.spr(items.Count()-1));
20410 curItem->PriceIndex = i;
20411 newcombo const& cmb = combobuf[bst.comb[i]];
20412 curItem->o_tile = cmb.o_tile;
20413 curItem->o_cset = bst.cset[i];
20414 curItem->cs = curItem->o_cset;
20415 curItem->tile = cmb.o_tile;
20416 curItem->o_speed = cmb.speed;
20417 curItem->o_delay = 0;
20418 curItem->frames = cmb.frames;
20419 curItem->flip = cmb.flip;
20420 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20421 curItem->pstring = 0;
20422 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20423 curItem->flash = false;
20424 curItem->twohand = false;
20425 curItem->anim = true;
20426 curItem->hit_width=1;
20427 curItem->hyofs=4;
20428 curItem->hit_height=12;
20429 curItem->script=0;
20430 curItem->txsz=1;
20431 curItem->tysz=1;
20432 //}
20433
20434 prices[i] = bst.price[i];
20435 if(prices[i]==0)
20436 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20437 int32_t itemid = current_item_id(itype_wealthmedal);
20438
20439 if(itemid>=0 && prices[i]!=100000)
20440 {
20441 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20442 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20443 else
20444 prices[i]+=itemsbuf[itemid].misc1;
20445 prices[i]=vbound(prices[i], 0, 99999);
20446 if(prices[i]==0)
20447 prices[i]=100000;
20448 }
20449
20450 if((bst.price[i])>1 && prices[i]<1)
20451 prices[i]=1;
20452 }
20453
20454 break;
20455 }
20456
20457 case rBOMBS: // more bombs
20458 12 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20459 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20460 12 prices[0]=-tmpscr[t].catchall;
20461 12 break;
20462
20463 case rARROWS: // more arrows
20464 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20465 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20466 prices[0]=-tmpscr[t].catchall;
20467 break;
20468
20469 case rSWINDLE: // leave heart container or money
20470 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20471 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20472 13 prices[0]=-1;
20473 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20474 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20475 13 prices[1]=-tmpscr[t].catchall;
20476 13 break;
20477
20478 }
20479
20480
3/4
✓ Branch 0 taken 709 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 709 times.
721 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20481 {
20482 12 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20483 12 int32_t itemid = current_item_id(itype_wealthmedal);
20484
20485
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itemid >= 0)
20486 {
20487 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20488 prices[i]*=(itemsbuf[itemid].misc1/100.0);
20489 else
20490 prices[i]+=itemsbuf[itemid].misc1;
20491 }
20492
20493
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(tmpscr[t].catchall>1 && prices[i]>-1)
20494 prices[i]=-1;
20495 12 }
20496
20497 721 putprices(false);
20498
20499
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 35 times.
721 if(str)
20500 {
20501 686 donewmsg(str);
20502 686 }
20503 else
20504 {
20505 35 Hero.unfreeze();
20506 }
20507 721 }
20508
20509 // Increments msgptr and returns the control code argument pointed at.
20510 658 word grab_next_argument()
20511 {
20512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20513 658 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20514 658 word ret=val;
20515
20516 // If an argument is succeeded by 255, then it's a three-byte argument -
20517 // between 254 and 65535 (or whatever the maximum actually is)
20518
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20519
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20520 {
20521 val=MsgStrings[msgstr].s[msgptr+2];
20522 word next=val;
20523 ret += 254*next;
20524 msgptr+=2;
20525 }
20526
20527 658 return ret;
20528 658 }
20529
20530 enum
20531 {
20532 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20533 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20534
20535 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20536
20537 MNU_DATA_MAX
20538 };
20539 struct menu_choice
20540 {
20541 int32_t x, y;
20542 int32_t pos;
20543 int32_t upos, dpos, lpos, rpos;
20544 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20545 {}
20546 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20547 int32_t dpos, int32_t lpos, int32_t rpos)
20548 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20549 {}
20550 };
20551 static int32_t msg_menu_data[MNU_DATA_MAX];
20552 static bool do_run_menu = false;
20553 bool do_end_str = false;
20554 static bool wait_advance = false;
20555 46 static std::map<int32_t, menu_choice> menu_options;
20556 19295 void clr_msg_data()
20557 {
20558 19295 do_end_str = false;
20559 19295 wait_advance = false;
20560 19295 do_run_menu = false;
20561 19295 menu_options.clear();
20562 19295 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20563 19295 }
20564
20565 static bool doing_name_insert = false;
20566 static char namebuf[9] = {0};
20567 static char* nameptr = NULL;
20568 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20569 bool runMenuCursor()
20570 {
20571 clear_bitmap(msg_menu_bmp_buf);
20572 if(!menu_options.size())
20573 {
20574 msg_menu_data[MNU_CHOSEN] = 0;
20575 return true; //end menu
20576 }
20577 int32_t pos = msg_menu_data[MNU_CHOSEN];
20578 //If the cursor is at an invalid pos, find the first pos >= 0...
20579 if(menu_options.find(pos) == menu_options.end())
20580 {
20581 pos = 0;
20582 while(menu_options.find(pos) == menu_options.end())
20583 ++pos;
20584 }
20585 menu_choice* ch = &menu_options[pos];
20586
20587 bool pressed = true;
20588 if(rUp()) pos = ch->upos;
20589 else if(rDown()) pos = ch->dpos;
20590 else if(rLeft()) pos = ch->lpos;
20591 else if(rRight()) pos = ch->rpos;
20592 else pressed = false;
20593
20594 if(pressed)
20595 msg_menu_data[MNU_TIMER] = 1;
20596
20597 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 5);
20598 bool held = false;
20599 if(hold_input)
20600 {
20601 held = true;
20602 if(Up()) pos = ch->upos;
20603 else if(Down()) pos = ch->dpos;
20604 else if(Left()) pos = ch->lpos;
20605 else if(Right()) pos = ch->rpos;
20606 else held = false;
20607 }
20608 //If the cursor is at an invalid pos, find the first pos >= 0...
20609 if(menu_options.find(pos) == menu_options.end())
20610 {
20611 pos = 0;
20612 while(menu_options.find(pos) == menu_options.end())
20613 ++pos;
20614 }
20615 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20616 sfx(MsgStrings[msgstr].sfx);
20617
20618 ch = &menu_options[pos];
20619 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20620 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20621 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20622 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20623
20624 msg_menu_data[MNU_CHOSEN] = pos;
20625
20626 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20627 {
20628 rAbtn(); //Eat
20629 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20630 }
20631
20632 bool ret = (pressed || held) ? false : rAbtn();
20633 //Eat inputs
20634 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20635
20636 if(ret)
20637 menu_options.clear();
20638
20639 return ret;
20640 //false if pos changed this frame; no confirming while moving the cursor!
20641 }
20642
20643 184952 bool bottom_margin_clip()
20644 {
20645 185252 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20646
2/2
✓ Branch 0 taken 184652 times.
✓ Branch 1 taken 300 times.
184952 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20647 }
20648
20649 void update_msgstr();
20650 98407 bool parsemsgcode()
20651 {
20652
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 97806 times.
98407 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20653 97806 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20654
5/38
✗ Branch 0 not taken.
✓ Branch 1 taken 97457 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
97806 switch(c)
20655 {
20656 case MSGC_NEWLINE:
20657 {
20658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20659 1 ssc_tile_hei = ssc_tile_hei_buf;
20660 1 ssc_tile_hei_buf = -1;
20661 1 cursor_y += thei + MsgStrings[msgstr].vspace;
20662 1 cursor_x=msg_margins[left];
20663 1 return true;
20664 }
20665
20666 case MSGC_COLOUR:
20667 {
20668 310 int32_t cset = (grab_next_argument());
20669 310 msgcolour = CSET(cset)+(grab_next_argument());
20670 310 return true;
20671 }
20672
20673 case MSGC_SHDCOLOR:
20674 {
20675 int32_t cset = (grab_next_argument());
20676 msg_shdcol = CSET(cset)+(grab_next_argument());
20677 return true;
20678 }
20679 case MSGC_SHDTYPE:
20680 {
20681 msg_shdtype = grab_next_argument();
20682 return true;
20683 }
20684
20685 case MSGC_SPEED:
20686 {
20687 28 msgspeed=grab_next_argument();
20688 28 return true;
20689 }
20690
20691 case MSGC_CTRUP:
20692 {
20693 int32_t a1 = grab_next_argument();
20694 int32_t a2 = grab_next_argument();
20695 game->change_counter(a2, a1);
20696 return true;
20697 }
20698
20699 case MSGC_CTRDN:
20700 {
20701 int32_t a1 = grab_next_argument();
20702 int32_t a2 = grab_next_argument();
20703 game->change_counter(-a2, a1);
20704 return true;
20705 }
20706
20707 case MSGC_CTRSET:
20708 {
20709 int32_t a1 = grab_next_argument();
20710 int32_t a2 = grab_next_argument();
20711 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20712 return true;
20713 }
20714
20715 case MSGC_CTRUPPC:
20716 case MSGC_CTRDNPC:
20717 case MSGC_CTRSETPC:
20718 {
20719 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20720 int32_t counter = grab_next_argument();
20721 int32_t amount = grab_next_argument();
20722 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20723
20724 if(code==MSGC_CTRDNPC)
20725 amount*=-1;
20726
20727 if(code==MSGC_CTRSETPC)
20728 game->set_counter(amount, counter);
20729 else
20730 game->change_counter(amount, counter);
20731
20732 return true;
20733 }
20734
20735 case MSGC_GIVEITEM:
20736 {
20737 int32_t itemID = grab_next_argument();
20738
20739 getitem(itemID, true);
20740 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20741 {
20742 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20743 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0;
20744 }
20745 return true;
20746 }
20747
20748
20749 case MSGC_WARP:
20750 {
20751 int32_t dmap = grab_next_argument();
20752 int32_t scrn = grab_next_argument();
20753 int32_t dx = grab_next_argument();
20754 int32_t dy = grab_next_argument();
20755 int32_t wfx = grab_next_argument();
20756 int32_t sfx = grab_next_argument();
20757 if(dx >= MAX_SCC_ARG) dx = -1;
20758 if(dy >= MAX_SCC_ARG) dy = -1;
20759 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
20760 return true;
20761 }
20762
20763 case MSGC_SETSCREEND:
20764 {
20765 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20766 int32_t screen = grab_next_argument();
20767 int32_t reg = grab_next_argument();
20768 int32_t val = grab_next_argument();
20769 FFCore.set_screen_d(screen + dmap, reg, val);
20770 return true;
20771 }
20772 case MSGC_TAKEITEM:
20773 {
20774 int32_t itemID = grab_next_argument();
20775 if ( FFCore.doscript(ScriptType::Item, itemID) )
20776 {
20777 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20778 }
20779 takeitem(itemID);
20780 if ( game->forced_bwpn == itemID )
20781 {
20782 game->forced_bwpn = -1;
20783 } //not else if! -Z
20784 if ( game->forced_awpn == itemID )
20785 {
20786 game->forced_awpn = -1;
20787 }
20788 if ( game->forced_xwpn == itemID )
20789 {
20790 game->forced_xwpn = -1;
20791 } //not else if! -Z
20792 if ( game->forced_ywpn == itemID )
20793 {
20794 game->forced_ywpn = -1;
20795 }
20796 verifyBothWeapons();
20797 return true;
20798 }
20799
20800 case MSGC_SFX:
20801 {
20802 10 sfx((int32_t)grab_next_argument(),128);
20803 10 return true;
20804 }
20805
20806 case MSGC_MIDI:
20807 {
20808 int32_t music = (int32_t)(grab_next_argument());
20809
20810 if(music==0)
20811 music_stop();
20812 else
20813 jukebox(music+(ZC_MIDI_COUNT-1));
20814
20815 return true;
20816 }
20817
20818 case MSGC_NAME:
20819 {
20820 doing_name_insert = true;
20821 sprintf(namebuf, "%s", game->get_name());
20822 nameptr = namebuf;
20823 return true;
20824 }
20825
20826 case MSGC_FONT:
20827 {
20828 int fontid = grab_next_argument();
20829 int oh = text_height(msgfont);
20830 msgfont = get_zc_font(fontid);
20831 int nh = text_height(msgfont);
20832 int mh = std::max(oh,nh);
20833 if(mh > ssc_tile_hei_buf)
20834 ssc_tile_hei_buf = mh;
20835 return true;
20836 }
20837 case MSGC_RUN_FRZ_GENSCR:
20838 {
20839 word scr_id = grab_next_argument();
20840 bool force_redraw = grab_next_argument()!=0;
20841 if(force_redraw)
20842 {
20843 update_msgstr();
20844 draw_screen(tmpscr);
20845 }
20846 FFCore.runGenericFrozenEngine(scr_id);
20847 return true;
20848 }
20849 case MSGC_DRAWTILE:
20850 {
20851 int32_t tl = grab_next_argument();
20852 int32_t cs = grab_next_argument();
20853 int32_t t_wid = grab_next_argument();
20854 int32_t t_hei = grab_next_argument();
20855 int32_t fl = grab_next_argument();
20856
20857 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20858 {
20859 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20860 ssc_tile_hei = ssc_tile_hei_buf;
20861 ssc_tile_hei_buf = -1;
20862 cursor_y += thei + MsgStrings[msgstr].vspace;
20863 if(bottom_margin_clip()) return true;
20864 cursor_x=msg_margins[left];
20865 }
20866
20867 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20868 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20869 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20870 return true;
20871 }
20872
20873 case MSGC_GOTOIFRAND:
20874 {
20875 int32_t odds = (int32_t)(grab_next_argument());
20876
20877 if(!odds || !(zc_oldrand()%odds))
20878 goto switched;
20879
20880 (void)grab_next_argument();
20881 return true;
20882 }
20883
20884 case MSGC_GOTOIFGLOBAL:
20885 {
20886 int32_t arg = (int32_t)grab_next_argument();
20887 int32_t d = zc_min(7,arg);
20888 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20889 arg = (int32_t)grab_next_argument();
20890
20891 if(game->screen_d[s][d] >= arg)
20892 goto switched;
20893
20894 (void)grab_next_argument();
20895 return true;
20896 }
20897
20898 case MSGC_CHANGEPORTRAIT:
20899 {
20900 return true; //not implemented
20901 }
20902
20903 case MSGC_GOTOIFCREEND:
20904 {
20905 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20906 int32_t screen = grab_next_argument();
20907 int32_t reg = grab_next_argument();
20908 int32_t val = grab_next_argument();
20909 //int32_t nxtstr = grab_next_argument();
20910 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20911 {
20912 goto switched;
20913 }
20914 (void)grab_next_argument();
20915 return true;
20916 }
20917
20918 case MSGC_GOTOIF:
20919 {
20920 int32_t it = (int32_t)grab_next_argument();
20921
20922 if(unsigned(it)<MAXITEMS && game->item[it])
20923 goto switched;
20924
20925 (void)grab_next_argument();
20926 return true;
20927 }
20928
20929 case MSGC_GOTOIFCTR:
20930 {
20931 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20932 goto switched;
20933
20934 (void)grab_next_argument();
20935 return true;
20936 }
20937
20938 case MSGC_GOTOIFCTRPC:
20939 {
20940 int32_t counter = grab_next_argument();
20941 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20942
20943 if(game->get_counter(counter)>=amount)
20944 goto switched;
20945
20946 (void)grab_next_argument();
20947 return true;
20948 }
20949
20950 case MSGC_GOTOIFTRICOUNT:
20951 {
20952 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20953 goto switched;
20954
20955 (void)grab_next_argument();
20956 return true;
20957 }
20958
20959 case MSGC_GOTOIFTRI:
20960 {
20961 int32_t lev = (int32_t)(grab_next_argument());
20962
20963 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20964 goto switched;
20965
20966 (void)grab_next_argument();
20967 return true;
20968 }
20969
20970 case MSGC_SETUPMENU:
20971 {
20972 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20973 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20974 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20975 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20976 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20977 return true;
20978 }
20979
20980 case MSGC_MENUCHOICE:
20981 {
20982 int32_t pos = grab_next_argument();
20983 int32_t upos = grab_next_argument();
20984 int32_t dpos = grab_next_argument();
20985 int32_t lpos = grab_next_argument();
20986 int32_t rpos = grab_next_argument();
20987 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20988 {
20989 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20990 ssc_tile_hei = ssc_tile_hei_buf;
20991 ssc_tile_hei_buf = -1;
20992 cursor_y += thei + MsgStrings[msgstr].vspace;
20993 if(bottom_margin_clip()) break;
20994 cursor_x=msg_margins[left];
20995 }
20996
20997 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20998 upos, dpos, lpos, rpos);
20999
21000 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
21001 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
21002 return true;
21003 }
21004
21005 case MSGC_RUNMENU:
21006 {
21007 msg_menu_data[MNU_CHOSEN] = 0;
21008 msg_menu_data[MNU_CAN_CONFIRM] = 0;
21009 if(menu_options.size() < 1)
21010 return true;
21011 do_run_menu = true;
21012 return true;
21013 }
21014
21015 case MSGC_GOTOMENUCHOICE:
21016 {
21017 int32_t choice = grab_next_argument();
21018 if(msg_menu_data[MNU_CHOSEN] == choice)
21019 goto switched;
21020 (void)grab_next_argument();
21021 return true;
21022 }
21023
21024 case MSGC_ENDSTRING:
21025 {
21026 do_end_str = true;
21027 return true;
21028 }
21029 case MSGC_WAIT_ADVANCE:
21030 {
21031 wait_advance = true;
21032 linkedmsgclk = 51;
21033 return true;
21034 }
21035 case MSGC_TRIGSECRETS:
21036 {
21037 bool perm = (bool)grab_next_argument();
21038 hidden_entrance(0, true, false, -8);
21039 if(perm)
21040 setmapflag(mSECRET);
21041 return true;
21042 }
21043 case MSGC_SETSCREENSTATE:
21044 {
21045 int32_t flag = int32_t(grab_next_argument());
21046 if(unsigned(flag)>=mMAXIND)
21047 {
21048 Z_error("SCC 133: Flag %d is invalid\n", flag);
21049 return true;
21050 }
21051 bool state = bool(grab_next_argument());
21052 if(state)
21053 setmapflag(1<<flag);
21054 else
21055 unsetmapflag(1<<flag,true);
21056 return true;
21057 }
21058 case MSGC_SETSCREENSTATER:
21059 {
21060 int32_t map = (int32_t)grab_next_argument();
21061 int32_t scrid = (int32_t)grab_next_argument();
21062 if(map < 1 || map > map_count)
21063 {
21064 Z_error("SCC 134: Map %d is invalid\n", map);
21065 return true;
21066 }
21067 if(unsigned(scrid)>=0x80)
21068 {
21069 Z_error("SCC 134: Screen %d is invalid\n", scrid);
21070 return true;
21071 }
21072
21073 int32_t flag = int32_t(grab_next_argument());
21074 if(unsigned(flag)>=mMAXIND)
21075 {
21076 Z_error("SCC 134: Flag %d is invalid\n", flag);
21077 return true;
21078 }
21079 bool state = bool(grab_next_argument());
21080 if(state)
21081 setmapflag(mapind(map,scrid),1<<flag);
21082 else
21083 unsetmapflag(mapind(map,scrid),1<<flag,true);
21084 return true;
21085 }
21086 switched:
21087 int32_t lev = (int32_t)(grab_next_argument());
21088 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
21089 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
21090 {
21091 msgstr=lev;
21092 msgpos=msgptr=0;
21093 msgfont=setmsgfont();
21094 }
21095 else donewmsg(lev);
21096 msgptr--; // To counteract it being incremented after this routine is called.
21097 putprices(false);
21098 return true;
21099 }
21100
21101 97457 return false;
21102 98407 }
21103
21104 // Wraps the message string... probably.
21105 95975 void wrapmsgstr(char *s3)
21106 {
21107 95975 int32_t j=0;
21108
21109
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 86296 times.
95975 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21110 {
21111
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
21112 {
21113 2081 char c = MsgStrings[msgstr].s[msgptr];
21114
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
21115 {
21116
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
21117 {
21118
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
21119 8026 }
21120
21121 1786 s3[j] = 0;
21122 1786 msgspace = false;
21123 1786 }
21124 else
21125 {
21126 295 s3[0] = c;
21127 295 s3[1] = 0;
21128 }
21129 2081 }
21130 else
21131 {
21132 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
21133 7598 s3[1] = 0;
21134
21135
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
21136 }
21137 9679 }
21138 else
21139 {
21140 86296 s3[0] = MsgStrings[msgstr].s[msgptr];
21141 86296 s3[1] = 0;
21142 }
21143 95975 }
21144
21145 // Returns true if the pointer is at a string's
21146 // null terminator or a trailing space
21147 251744 bool atend(char const* str)
21148 {
21149 251744 int32_t i=0;
21150
21151
2/2
✓ Branch 0 taken 1563482 times.
✓ Branch 1 taken 251744 times.
1815226 while(str[i]==' ')
21152 1563482 i++;
21153
21154 251744 return str[i]=='\0';
21155 }
21156
21157 7284780 void putmsg()
21158 {
21159 7284780 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
21160
2/2
✓ Branch 0 taken 259916 times.
✓ Branch 1 taken 7024864 times.
7284780 if(!msgorig) msgorig=msgstr;
21161
21162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7284780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7284780 if(wait_advance && linkedmsgclk < 1)
21163 linkedmsgclk = 1;
21164
2/2
✓ Branch 0 taken 7188643 times.
✓ Branch 1 taken 96137 times.
7284780 if(linkedmsgclk>0)
21165 {
21166
2/2
✓ Branch 0 taken 45486 times.
✓ Branch 1 taken 50651 times.
96137 if(linkedmsgclk==1)
21167 {
21168
5/6
✓ Branch 0 taken 45486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44557 times.
✓ Branch 3 taken 929 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 44473 times.
45486 if(do_end_str||cAbtn()||cBbtn())
21169 {
21170 1013 do_end_str = false;
21171 1013 linkedmsgclk = 0;
21172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1013 times.
1013 if(wait_advance)
21173 {
21174 wait_advance = false;
21175 }
21176 else
21177 {
21178 1013 msgstr=MsgStrings[msgstr].nextstring;
21179
3/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 836 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
1013 if(!msgstr && enqueued_str)
21180 {
21181 msgstr = enqueued_str;
21182 enqueued_str = 0;
21183 }
21184
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 177 times.
1013 if(!msgstr)
21185 {
21186 177 msgfont=get_zc_font(font_zfont);
21187
21188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(tmpscr->room!=rGRUMBLE)
21189 177 blockpath=false;
21190
21191 177 dismissmsg();
21192 177 goto disappear;
21193 }
21194
21195 836 donewmsg(msgstr);
21196 836 putprices(false);
21197 }
21198 836 }
21199 45309 }
21200 else
21201 {
21202 50651 --linkedmsgclk;
21203 }
21204 95960 }
21205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7284603 times.
7284603 if(wait_advance) return; //Waiting for buttonpress
21206
21207
9/10
✓ Branch 0 taken 7284473 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 258769 times.
✓ Branch 3 taken 7025704 times.
✓ Branch 4 taken 125265 times.
✓ Branch 5 taken 133504 times.
✓ Branch 6 taken 64562 times.
✓ Branch 7 taken 60703 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64562 times.
7284603 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
21208 {
21209
2/2
✓ Branch 0 taken 194207 times.
✓ Branch 1 taken 7025704 times.
7219911 if(!msgstr)
21210 7025704 msgorig=0;
21211
21212 7219911 msg_active = false;
21213 7219911 return;
21214 }
21215
21216 64692 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21217
21218 char s3[145];
21219 int32_t tlength;
21220
21221 // Bypass the string with the B button!
21222
4/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 64361 times.
✓ Branch 2 taken 997 times.
✓ Branch 3 taken 63364 times.
64692 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
21223 {
21224 //finish writing out the string
21225
4/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 77095 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 75991 times.
77317 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
21226 {
21227
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 58989 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
75991 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21228 goto breakout; // break out if message speed was changed to non-zero
21229
5/6
✓ Branch 0 taken 75989 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 75989 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 234 times.
✓ Branch 5 taken 75755 times.
75991 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21230 {
21231
1/2
✓ Branch 0 taken 75755 times.
✗ Branch 1 not taken.
75755 if(bottom_margin_clip())
21232 break;
21233
21234 75755 wrapmsgstr(s3);
21235
21236
2/2
✓ Branch 0 taken 20122 times.
✓ Branch 1 taken 55633 times.
75755 if(MsgStrings[msgstr].s[msgptr]==' ')
21237 {
21238 20122 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21239
21240
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1347 times.
21512 if(cursor_x+tlength > (msg_w-msg_margins[right])
21241
5/6
✓ Branch 0 taken 1390 times.
✓ Branch 1 taken 18732 times.
✓ Branch 2 taken 1390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1388 times.
✓ Branch 5 taken 41 times.
20122 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21242 43 ? true : strcmp(s3," ")!=0))
21243 {
21244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1347 times.
1431 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21245 1347 ssc_tile_hei = ssc_tile_hei_buf;
21246 1347 ssc_tile_hei_buf = -1;
21247 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
21248
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
21249 1347 cursor_x=msg_margins[left];
21250 1347 }
21251
21252 20120 char buf[2] = {0};
21253 20120 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21254
21255 20120 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21256
21257 20120 cursor_x+=tlength;
21258 20120 }
21259 else
21260 {
21261 55633 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21262
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 533 times.
56334 if(cursor_x+tlength > (msg_w-msg_margins[right])
21263
5/6
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 54889 times.
✓ Branch 2 taken 701 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
55633 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21264 168 ? true : strcmp(s3," ")!=0))
21265 {
21266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744 times.
744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21267 744 ssc_tile_hei = ssc_tile_hei_buf;
21268 744 ssc_tile_hei_buf = -1;
21269 744 cursor_y += thei + MsgStrings[msgstr].vspace;
21270
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(bottom_margin_clip()) break;
21271 744 cursor_x=msg_margins[left];
21272 744 }
21273
21274 55633 sfx(MsgStrings[msgstr].sfx);
21275
21276 55633 char buf[2] = {0};
21277 55633 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21278
21279 55633 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21280
21281 55633 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21282 55633 cursor_x += MsgStrings[msgstr].hspace;
21283 }
21284
21285 75753 msgpos++;
21286 75753 }
21287
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_run_menu)
21288 {
21289 if(runMenuCursor())
21290 {
21291 do_run_menu = false;
21292 }
21293 else break;
21294 }
21295
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(doing_name_insert)
21296 {
21297 if(*nameptr)
21298 {
21299 if(bottom_margin_clip())
21300 break;
21301
21302 char s3[9] = {0};
21303
21304 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21305 {
21306 strcpy(s3, nameptr);
21307 }
21308 else
21309 {
21310 s3[0] = *nameptr;
21311 s3[1] = 0;
21312 }
21313
21314 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21315
21316 if(cursor_x+tlength > (msg_w-msg_margins[right])
21317 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21318 ? true : strcmp(s3," ")!=0))
21319 {
21320 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21321 ssc_tile_hei = ssc_tile_hei_buf;
21322 ssc_tile_hei_buf = -1;
21323 cursor_y += thei + MsgStrings[msgstr].vspace;
21324 if(bottom_margin_clip()) break;
21325 cursor_x=msg_margins[left];
21326 }
21327
21328 sfx(MsgStrings[msgstr].sfx);
21329
21330 char buf[2] = {0};
21331 sprintf(buf,"%c",*nameptr);
21332
21333 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21334
21335 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21336 cursor_x += MsgStrings[msgstr].hspace;
21337 ++nameptr;
21338 continue; //don't advance the msgptr, as the next char in it was not processed!
21339 }
21340 else doing_name_insert = false;
21341 }
21342 75989 ++msgptr;
21343
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_end_str)
21344 goto strendcheck;
21345
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(wait_advance)
21346 return;
21347
2/2
✓ Branch 0 taken 74810 times.
✓ Branch 1 taken 1179 times.
75989 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21348 {
21349
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 776 times.
1179 if(MsgStrings[msgstr].nextstring)
21350 {
21351
1/2
✓ Branch 0 taken 776 times.
✗ Branch 1 not taken.
776 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21352 {
21353 msgstr=MsgStrings[msgstr].nextstring;
21354 msgpos=msgptr=0;
21355 msgfont=setmsgfont();
21356 }
21357 776 }
21358 1179 }
21359 }
21360
21361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1198 times.
1198 if (!do_run_menu)
21362 {
21363 1198 msgclk = 72;
21364 1198 msgpos = 10000;
21365 1198 }
21366 1198 }
21367 else
21368 63364 {
21369 breakout:
21370
21371
6/6
✓ Branch 0 taken 52672 times.
✓ Branch 1 taken 10692 times.
✓ Branch 2 taken 15055 times.
✓ Branch 3 taken 37617 times.
✓ Branch 4 taken 10249 times.
✓ Branch 5 taken 4806 times.
63364 if(((msgclk++)%(msgspeed+1)<msgspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21372 42423 return;
21373 }
21374
21375 // Start writing the string
21376
2/2
✓ Branch 0 taken 21530 times.
✓ Branch 1 taken 609 times.
22748 if(msgptr == 0)
21377 {
21378
2/2
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 2415 times.
3024 while(MsgStrings[msgstr].s[msgptr]==' ')
21379 {
21380 2415 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21381
21382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
2456 if(cursor_x+tlength > (msg_w-msg_margins[right])
21383
4/6
✓ Branch 0 taken 2374 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
2415 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21384 ? 1 : strcmp(s3," ")!=0))
21385 {
21386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21387 41 ssc_tile_hei = ssc_tile_hei_buf;
21388 41 ssc_tile_hei_buf = -1;
21389 41 cursor_y += thei + MsgStrings[msgstr].vspace;
21390
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(bottom_margin_clip()) break;
21391 41 cursor_x=msg_margins[left];
21392 41 }
21393
21394 2415 cursor_x+=tlength;
21395 2415 ++msgptr;
21396 2415 ++msgpos;
21397
21398 // The "Continue From Previous" feature
21399
2/2
✓ Branch 0 taken 1047 times.
✓ Branch 1 taken 1368 times.
2415 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21400 {
21401
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21402 {
21403 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21404 {
21405 msgstr=MsgStrings[msgstr].nextstring;
21406 msgpos=msgptr=0;
21407 msgfont=setmsgfont();
21408 }
21409 }
21410 1368 }
21411 }
21412 609 }
21413
21414 reparsesinglechar:
21415 // Continue printing the string!
21416
3/4
✓ Branch 0 taken 20335 times.
✓ Branch 1 taken 1804 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20335 times.
42474 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21417 {
21418
4/6
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
✓ Branch 5 taken 20222 times.
20335 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21419 {
21420 20222 wrapmsgstr(s3);
21421
21422 20222 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21423
21424
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 236 times.
20478 if(cursor_x+tlength > (msg_w-msg_margins[right])
21425
6/6
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 19962 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 4 times.
20222 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21426 20 ? true : strcmp(s3," ")!=0))
21427 {
21428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21429 256 ssc_tile_hei = ssc_tile_hei_buf;
21430 256 ssc_tile_hei_buf = -1;
21431 256 cursor_y += thei + MsgStrings[msgstr].vspace;
21432
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(bottom_margin_clip()) goto strendcheck;
21433 256 cursor_x=msg_margins[left];
21434 //if(space) s3[0]=0;
21435 256 }
21436
21437 20222 sfx(MsgStrings[msgstr].sfx);
21438
21439 20222 char buf[2] = {0};
21440 20222 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21441
21442 20222 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21443
21444 20222 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21445 20222 cursor_x += MsgStrings[msgstr].hspace;
21446 20222 msgpos++;
21447 20222 }
21448
1/2
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
20335 if(do_end_str)
21449 goto strendcheck;
21450
1/2
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
20335 if(wait_advance)
21451 {
21452 ++msgptr;
21453 return;
21454 }
21455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335 times.
20335 else if(do_run_menu)
21456 {
21457 if(runMenuCursor())
21458 {
21459 do_run_menu = false;
21460 ++msgptr;
21461 goto reparsesinglechar;
21462 }
21463 }
21464
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20335 else if(doing_name_insert && *nameptr)
21465 {
21466 char s3[9] = {0};
21467
21468 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21469 {
21470 strcpy(s3, nameptr);
21471 }
21472 else
21473 {
21474 s3[0] = *nameptr;
21475 s3[1] = 0;
21476 }
21477
21478 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21479
21480 if(cursor_x+tlength > (msg_w-msg_margins[right])
21481 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21482 ? true : strcmp(s3," ")!=0))
21483 {
21484 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21485 ssc_tile_hei = ssc_tile_hei_buf;
21486 ssc_tile_hei_buf = -1;
21487 cursor_y += thei + MsgStrings[msgstr].vspace;
21488 if(bottom_margin_clip()) goto strendcheck;
21489 cursor_x=msg_margins[left];
21490 }
21491
21492 sfx(MsgStrings[msgstr].sfx);
21493
21494 char buf[2] = {0};
21495 sprintf(buf,"%c",*nameptr);
21496
21497 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21498
21499 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21500 cursor_x += MsgStrings[msgstr].hspace;
21501 ++nameptr;
21502 }
21503 else
21504 {
21505 20335 doing_name_insert = false;
21506 20335 msgptr++;
21507
21508
2/2
✓ Branch 0 taken 19832 times.
✓ Branch 1 taken 503 times.
20335 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21509 {
21510
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 61 times.
503 if(MsgStrings[msgstr].nextstring)
21511 {
21512
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21513 {
21514 msgstr=MsgStrings[msgstr].nextstring;
21515 msgpos=msgptr=0;
21516 msgfont=setmsgfont();
21517 }
21518 61 }
21519 503 }
21520
21521
2/2
✓ Branch 0 taken 2981 times.
✓ Branch 1 taken 1011 times.
24327 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21522
2/2
✓ Branch 0 taken 20288 times.
✓ Branch 1 taken 47 times.
20335 && (MsgStrings[msgstr].s[msgptr]==' ')
21523
2/2
✓ Branch 0 taken 3992 times.
✓ Branch 1 taken 16296 times.
20288 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21524 {
21525
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 33320 times.
34331 while(MsgStrings[msgstr].s[msgptr]==' ')
21526 {
21527 33320 msgspace = true;
21528 33320 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21529
21530
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1440 times.
34783 if(cursor_x+tlength > (msg_w-msg_margins[right])
21531
4/6
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 31857 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
33320 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21532 23 ? true : strcmp(s3," ")!=0))
21533 {
21534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
1463 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21535 1463 ssc_tile_hei = ssc_tile_hei_buf;
21536 1463 ssc_tile_hei_buf = -1;
21537 1463 cursor_y += thei + MsgStrings[msgstr].vspace;
21538
1/2
✓ Branch 0 taken 1463 times.
✗ Branch 1 not taken.
1463 if(bottom_margin_clip()) break;
21539 1463 cursor_x=msg_margins[left];
21540 1463 }
21541
21542 33320 cursor_x+=tlength;
21543 33320 ++msgpos;
21544 33320 ++msgptr;
21545
21546
2/2
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 30070 times.
33320 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21547 {
21548
2/2
✓ Branch 0 taken 25984 times.
✓ Branch 1 taken 4086 times.
30070 if(MsgStrings[msgstr].nextstring)
21549 {
21550
1/2
✓ Branch 0 taken 4086 times.
✗ Branch 1 not taken.
4086 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21551 {
21552 msgstr=MsgStrings[msgstr].nextstring;
21553 msgpos=msgptr=0;
21554 msgfont=setmsgfont();
21555 }
21556 4086 }
21557 30070 }
21558 }
21559 1011 }
21560 }
21561 20335 }
21562 strendcheck:
21563 // Done printing the string
21564
10/14
✓ Branch 0 taken 22139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20941 times.
✓ Branch 7 taken 1198 times.
✓ Branch 8 taken 20451 times.
✓ Branch 9 taken 490 times.
✓ Branch 10 taken 20451 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20056 times.
✓ Branch 13 taken 2083 times.
22139 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21565 {
21566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2083 times.
2083 if(!do_end_str)
21567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2083 times.
2083 while(parsemsgcode()); // Finish remaining control codes
21568
21569 // Go to next string, or make it disappear by going to string 0.
21570
5/6
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 1069 times.
✓ Branch 3 taken 177 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1069 times.
2083 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21571 {
21572 1014 linkedmsgclk=do_end_str?1:51;
21573 1014 }
21574
21575
2/2
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 837 times.
2083 if(MsgStrings[msgstr].nextstring==0)
21576 {
21577
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1069 times.
1246 if(!get_qr(qr_MSGDISAPPEAR))
21578 1069 {
21579 disappear:
21580 1246 msg_active = false;
21581 1246 Hero.finishedmsg();
21582 1246 }
21583
21584
2/2
✓ Branch 0 taken 1411 times.
✓ Branch 1 taken 12 times.
1423 if(repaircharge)
21585 {
21586 // if (get_qr(qr_REPAIRFIX)) {
21587 // fixed_door=true;
21588 // }
21589 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21590 12 repaircharge = 0;
21591 12 }
21592
21593
2/2
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 1 times.
1423 if(adjustmagic)
21594 {
21595
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_qr(qr_OLD_HALF_MAGIC))
21596 {
21597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
21598 1 game->set_magicdrainrate(1);
21599 1 }
21600 else if(game->get_magicdrainrate() > 1)
21601 {
21602 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21603 }
21604 1 adjustmagic = false;
21605 1 sfx(WAV_SCALE);
21606
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21607 1 }
21608
21609
2/2
✓ Branch 0 taken 1421 times.
✓ Branch 1 taken 2 times.
1423 if(learnslash)
21610 {
21611 2 game->set_canslash(1);
21612 2 learnslash = false;
21613 2 sfx(WAV_SCALE);
21614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21615 2 }
21616 1423 }
21617 2260 }
21618 7284650 }
21619
21620 45302 int32_t message_more_y()
21621 {
21622 //Is the flag ticked, do we really want a message more y larger than 160?
21623
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45288 times.
✓ Branch 2 taken 45302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45288 times.
✓ Branch 5 taken 14 times.
45302 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21624 45302 msgy+=playing_field_offset;
21625 45302 return msgy;
21626 }
21627
21628 /*** Collision detection & handling ***/
21629
21630 7261355 void clear_script_one_frame_conditions()
21631 {
21632
2/2
✓ Branch 0 taken 21644333 times.
✓ Branch 1 taken 7261355 times.
28905688 for(int32_t j=0; j<guys.Count(); j++)
21633 {
21634 21644333 enemy *e = (enemy*)guys.spr(j);
21635
2/2
✓ Branch 0 taken 367953661 times.
✓ Branch 1 taken 21644333 times.
389597994 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21636 21644333 }
21637 7261355 }
21638
21639 7261207 void check_collisions()
21640 {
21641
2/2
✓ Branch 0 taken 2980512 times.
✓ Branch 1 taken 7261207 times.
10241719 for(int32_t i=0; i<Lwpns.Count(); i++)
21642 {
21643 2980512 weapon *w = (weapon*)Lwpns.spr(i);
21644
21645
8/8
✓ Branch 0 taken 2516103 times.
✓ Branch 1 taken 464409 times.
✓ Branch 2 taken 2107862 times.
✓ Branch 3 taken 408241 times.
✓ Branch 4 taken 2086549 times.
✓ Branch 5 taken 21313 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 2072909 times.
2980512 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21646 {
21647
2/2
✓ Branch 0 taken 2062226 times.
✓ Branch 1 taken 7445354 times.
9507580 for(int32_t j=0; j<guys.Count(); j++)
21648 {
21649 7445354 enemy *e = (enemy*)guys.spr(j);
21650
21651 7445354 bool didhit = e->hit(w);
21652
2/2
✓ Branch 0 taken 7307623 times.
✓ Branch 1 taken 137731 times.
7445354 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21653 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21654 {
21655 // !(e->stunclk)
21656 137731 int32_t h = e->takehit(w);
21657
2/2
✓ Branch 0 taken 114502 times.
✓ Branch 1 taken 23229 times.
137731 if (h == -1)
21658 {
21659 23229 e->hitby[HIT_BY_LWEAPON] = i+1;
21660 23229 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21661 23229 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21662
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 21566 times.
23229 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21663 1663 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21664 23229 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21665 23229 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21666
21667 23229 }
21668 //we may need to handle this in special cases. -Z
21669
21670 //if h == stun or ignore
21671
21672 //if e->stun > DEFAULT_STUN -1 || !e->stun
21673 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21674 ///! how about: if w->dead != bounce !
21675
21676 // NOT FOR PUBLIC RELEASE
21677 /*if(h==3) //Mirror shield
21678 {
21679 if (w->id==ewFireball || w->id==wRefFireball)
21680 {
21681 w->id=wRefFireball;
21682 switch(e->dir)
21683 {
21684 case up: e->angle += (PI - e->angle) * 2.0; break;
21685 case down: e->angle = -e->angle; break;
21686 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21687 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21688 // TODO: the following. -L.
21689 case l_up: break;
21690 case r_up: break;
21691 case l_down: break;
21692 case r_down: break;
21693 }
21694 }
21695 else
21696 {
21697 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21698 w->dir ^= 1;
21699 if(w->dir&2)
21700 w->flip ^= 1;
21701 else
21702 w->flip ^= 2;
21703 }
21704 w->ignoreHero=false;
21705 }
21706 else*/
21707
2/2
✓ Branch 0 taken 107377 times.
✓ Branch 1 taken 30354 times.
137731 if(h)
21708 {
21709
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30354 if(e->switch_hooked && w->family_class == itype_switchhook)
21710 w->onhit(false, e, -1);
21711 30354 else w->onhit(false, e, h);
21712 30354 }
21713
21714
2/2
✓ Branch 0 taken 135422 times.
✓ Branch 1 taken 2309 times.
137731 if(h==2)
21715 {
21716 2309 break;
21717 }
21718 135422 }
21719
21720
2/2
✓ Branch 0 taken 7434671 times.
✓ Branch 1 taken 8374 times.
7443045 if(w->Dead())
21721 {
21722 8374 break;
21723 }
21724 7434671 }
21725
21726 // Item flags added in 2.55:
21727 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
21728 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21729 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21730 // -V
21731
6/6
✓ Branch 0 taken 1760149 times.
✓ Branch 1 taken 312760 times.
✓ Branch 2 taken 1755673 times.
✓ Branch 3 taken 4476 times.
✓ Branch 4 taken 21925 times.
✓ Branch 5 taken 1733748 times.
2072909 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21732 {
21733 339161 int32_t itype, pitem = w->parentitem;
21734
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312760 times.
✓ Branch 2 taken 21925 times.
✓ Branch 3 taken 4476 times.
339161 switch(w->id)
21735 {
21736 312760 case wBrang: itype = itype_brang; break;
21737 21925 case wArrow: itype = itype_arrow; break;
21738 case wHookshot:
21739 4476 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21740 4476 break;
21741 }
21742
2/2
✓ Branch 0 taken 334309 times.
✓ Branch 1 taken 4852 times.
339161 if(pitem < 0) pitem = current_item_id(itype);
21743
5/6
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 334685 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4376 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
339161 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
21744 { //Swap with item
21745 for(int32_t j=0; j<items.Count(); j++)
21746 {
21747 if(items.spr(j)->hit(w))
21748 {
21749 item *theItem = ((item*)items.spr(j));
21750 bool priced = theItem->PriceIndex >-1;
21751 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21752 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21753 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21754 {
21755 if(!Hero.switchhookclk)
21756 {
21757 hooked_combopos = -1;
21758 hooked_layerbits = 0;
21759 switching_object = theItem;
21760 theItem->switch_hooked = true;
21761 w->misc = 2;
21762 w->step = 0;
21763 theItem->clk2=256;
21764 Hero.doSwitchHook(game->get_switchhookstyle());
21765 if(QMisc.miscsfx[sfxSWITCHED])
21766 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21767 }
21768 }
21769 }
21770 }
21771 }
21772
6/6
✓ Branch 0 taken 21925 times.
✓ Branch 1 taken 317236 times.
✓ Branch 2 taken 318320 times.
✓ Branch 3 taken 303763 times.
✓ Branch 4 taken 317236 times.
✓ Branch 5 taken 303763 times.
339161 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21773 {
21774
2/2
✓ Branch 0 taken 73578 times.
✓ Branch 1 taken 318320 times.
391898 for(int32_t j=0; j<items.Count(); j++)
21775 {
21776
2/2
✓ Branch 0 taken 69398 times.
✓ Branch 1 taken 4180 times.
73578 if(items.spr(j)->hit(w))
21777 {
21778 4180 item *theItem = ((item*)items.spr(j));
21779 4180 bool priced = theItem->PriceIndex >-1;
21780
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4096 times.
4180 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21781
5/8
✓ Branch 0 taken 4180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3363 times.
✓ Branch 5 taken 817 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1858 times.
6038 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21782
4/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 1858 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
4180 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
21783 {
21784
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
5221 if(itemsbuf[theItem->id].collect_script)
21785 {
21786 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21787 }
21788
21789 1505 Hero.checkitems(j);
21790 1505 }
21791 4180 }
21792 73578 }
21793 318320 }
21794
2/2
✓ Branch 0 taken 4872 times.
✓ Branch 1 taken 15969 times.
620999 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21795 {
21796
2/2
✓ Branch 0 taken 3337 times.
✓ Branch 1 taken 15969 times.
19306 for(int32_t j=0; j<items.Count(); j++)
21797 {
21798
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 935 times.
3337 if(items.spr(j)->hit(w))
21799 {
21800 935 item *theItem = ((item*)items.spr(j));
21801 935 bool priced = theItem->PriceIndex >-1;
21802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21803
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21804
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21805 {
21806 559 int32_t pickup = theItem->pickup;
21807 559 int32_t id2 = theItem->id;
21808 559 int32_t pstr = theItem->pstring;
21809 559 int32_t pstr_flags = theItem->pickup_string_flags;
21810
21811 559 std::vector<int32_t> &ev = FFCore.eventData;
21812 559 ev.clear();
21813 559 ev.push_back(id2*10000);
21814 559 ev.push_back(pickup*10000);
21815 559 ev.push_back(pstr*10000);
21816 559 ev.push_back(pstr_flags*10000);
21817 559 ev.push_back(0);
21818 559 ev.push_back(theItem->getUID());
21819 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21820 559 ev.push_back(w->getUID());
21821
21822 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21823 559 bool nullify = ev[4] != 0;
21824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
21825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
21826 {
21827 559 w->onhit(false);
21828 559 }
21829
21830
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
21831 {
21832 37 w->dead=1;
21833 37 theItem->clk2=256;
21834 37 w->dragging=j;
21835 37 theItem->is_dragged = true;
21836 37 }
21837 559 }
21838 935 }
21839 3337 }
21840 15969 }
21841 339161 }
21842 2072909 }
21843 2980512 }
21844 7261207 }
21845
21846 7261355 void dragging_item()
21847 {
21848
2/2
✓ Branch 0 taken 3041933 times.
✓ Branch 1 taken 7261355 times.
10303288 for(int32_t i=0; i<Lwpns.Count(); i++)
21849 {
21850 3041933 weapon *w = (weapon*)Lwpns.spr(i);
21851
21852
4/4
✓ Branch 0 taken 2722775 times.
✓ Branch 1 taken 319158 times.
✓ Branch 2 taken 3025626 times.
✓ Branch 3 taken 16307 times.
3041933 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
21853 {
21854
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
21855 {
21856 551 item* dragItem = (item*)items.spr(w->dragging);
21857 551 dragItem->x=w->x;
21858 551 dragItem->y=w->y;
21859
21860 // Drag the Fairy enemy as well as the Fairy item
21861 551 int32_t id = dragItem->id;
21862
21863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21864 {
21865 movefairynew2(w->x,w->y,*dragItem);
21866 }
21867 551 }
21868 16307 }
21869 3041933 }
21870 7261355 }
21871
21872 28 int32_t more_carried_items()
21873 {
21874 28 int32_t hasmorecarries = 0;
21875
21876
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 28 times.
59 for(int32_t i=0; i<items.Count(); i++)
21877 {
21878
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 28 times.
31 if(((item*)items.spr(i))->pickup & ipENEMY)
21879 {
21880 28 hasmorecarries++;
21881 28 }
21882 31 }
21883
21884 28 return hasmorecarries;
21885 }
21886
21887 // messy code to do the enemy-carrying-the-item thing
21888 7261355 void roaming_item()
21889 {
21890
4/4
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 7248117 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 13198 times.
7261355 if(!(hasitem&(4|2)) || !loaded_enemies)
21891 7248157 return;
21892
21893 // All enemies already dead upon entering a room?
21894
1/2
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
13198 if(guys.Count()==0)
21895 {
21896 return;
21897 }
21898
21899 // Lost track of the carrier?
21900
5/6
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13196 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13187 times.
✓ Branch 5 taken 9 times.
13198 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21901 13196 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21902 {
21903 11 guycarryingitem=-1;
21904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 for(int32_t j=0; j<guys.Count(); j++)
21905 {
21906
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(((enemy*)guys.spr(j))->itemguy)
21907 {
21908 11 guycarryingitem=j;
21909 11 break;
21910 }
21911 24 }
21912 11 }
21913
21914
2/2
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 34 times.
13198 if(hasitem&4)
21915 {
21916 34 guycarryingitem = -1;
21917
21918
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 34 times.
263 for(int32_t i=0; i<guys.Count(); i++)
21919 {
21920
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 34 times.
229 if(((enemy*)guys.spr(i))->itemguy)
21921 {
21922 34 guycarryingitem = i;
21923 34 }
21924 229 }
21925
21926
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(guycarryingitem == -1) //This happens when "default enemies" such as
21927 {
21928 return; //eSHOOTFBALL are alive but enemies from the list
21929 } //are not. Defer to HeroClass::checkspecial().
21930
21931 34 int32_t Item=tmpscr->item;
21932
21933 34 hasitem &= ~4;
21934
21935
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21936 {
21937 60 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21938
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8 times.
34 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21939 );
21940 34 hasitem |= 2;
21941 34 }
21942 else
21943 {
21944 return;
21945 }
21946 34 }
21947
21948
2/2
✓ Branch 0 taken 13953 times.
✓ Branch 1 taken 13198 times.
27151 for(int32_t i=0; i<items.Count(); i++)
21949 {
21950
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 13198 times.
13953 if(((item*)items.spr(i))->pickup&ipENEMY)
21951 {
21952
2/2
✓ Branch 0 taken 8390 times.
✓ Branch 1 taken 4808 times.
13198 if(get_qr(qr_HIDECARRIEDITEMS))
21953 {
21954 8390 items.spr(i)->x = -128; // Awfully inelegant, innit?
21955 8390 items.spr(i)->y = -128;
21956 8390 }
21957
2/4
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4808 times.
4808 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21958 {
21959
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21960 {
21961 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21962 {
21963 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21964 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21965 }
21966 else
21967 {
21968 if(guys.spr(guycarryingitem)->extend >= 3)
21969 {
21970 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21971 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21972 }
21973 else
21974 {
21975 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21976 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21977 }
21978 }
21979 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21980 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21981 }
21982 else
21983 {
21984 4808 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21985 4808 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21986 4808 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21987 }
21988 4808 }
21989 13198 }
21990 13953 }
21991 7261355 }
21992
21993 bool enemy::IsBigAnim()
21994 {
21995 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21996 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21997 || anim == a4FRM8DIRB);
21998 }
21999
22000 const char *old_guy_string[OLDMAXGUYS] =
22001 {
22002 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
22003 // 020
22004 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
22005 // 025
22006 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
22007 // 030
22008 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
22009 // 035
22010 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
22011 // 040
22012 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
22013 // 045
22014 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
22015 // 050
22016 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
22017 // 055
22018 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
22019 // 060
22020 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
22021 // 065
22022 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
22023 // 070
22024 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
22025 // 075
22026 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
22027 // 080
22028 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
22029 // 085
22030 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
22031 // 090
22032 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
22033 // 095
22034 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
22035 // 100
22036 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
22037 // 105
22038 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
22039 // 110
22040 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
22041 // 115
22042 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
22043 // 120
22044 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
22045 // 125
22046 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
22047 // 130
22048 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
22049 // 135
22050 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
22051 // 140
22052 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
22053 // 145
22054 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
22055 // 150
22056 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
22057 // 155
22058 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
22059 // 160
22060 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
22061 // 165
22062 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
22063 // 170
22064 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
22065 // 175
22066 "Grappler Bug (HP) ", "Grappler Bug (MP) "
22067 };
22068